﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import Engine.Helpers.*;
    import Engine.Init.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Transactions.*;
    import Classes.util.*;
    import Classes.sim.*;
    import com.greensock.*;
    import flash.filters.*;
    import Modules.bandits.*;
    import Display.ValentineUI.*;
    import Display.FactoryUI.*;
    import Display.MarketUI.*;
    import Modules.franchise.display.*;
    import Display.VisitorCenterUI.*;
    import Display.UpgradesUI.*;
    import Display.CopsBanditsUI.*;
    import Modules.quest.Display.QuestManager.*;
    import GameMode.*;
    import Display.Toaster.*;
    import Display.NeighborUI.*;
    import Display.CollectionsUI.*;
    import Display.InventoryUI.*;
    import flash.text.*;
    import Modules.realtime.*;
    import Modules.storage.*;
    import Classes.inventory.*;
    import Modules.guide.ui.*;
    import Modules.stats.experiments.*;
    import flash.media.*;
    import Classes.orders.Valentines2011.*;
    import Classes.Managers.*;
    import Display.RenameUI.*;
    import flash.net.*;
    import Display.aswingui.*;
    import Display.PopulationUI.*;
    import Modules.storage.ui.*;
    import Engine.*;
    import Modules.stats.types.*;
    import L10n.*;
    import Display.hud.*;
    import fl.motion.easing.*;
    import com.zynga.skelly.util.*;
    import Modules.storage.modes.*;
    import Display.peddlerUI.peddlerMarketUI.*;
    import flash.ui.*;
    import flash.external.*;

    public class UI extends Sprite {

        private static const NUM_EMPTY_NEIGHBORS:int = 7;
        private static const MAX_CURSOR_SIZE:int = 50;
        private static const UI_BUTTON_CLICKS_COUNTER:String = "ui_button_clicks";
        public static const DEFAULT_STATUS_TWEEN_DURATION:Number = 1.5;
        public static const DEFAULT_STATUS_TWEEN_DISPLACEMENT:int = 32;
        public static const SCREEN_MENU_BUFFER:int = 10;
        public static const MASK_GAME:int = 0;
        public static const MASK_GAME_AND_BOTTOMBAR:int = 1;
        public static const MASK_ALL_UI:int = 2;
        private static const FROZEN_GRAY_PERCENT:Number = 0.33;
        public static const CURSOR_OFFSET_X:int = 10;
        public static const CURSOR_OFFSET_Y:int = 10;
        public static const MAX_CURSOR_DISTANCE:int = 120;

        public static var AUTO_CLOSE_MARKET:Boolean = false;
        private static var m_isFreezing:Boolean = false;
        private static var m_frozenFrameRate:Number = -1;
        private static var m_frozenGrayRect:Shape;
        private static var m_marketWindow:Market = null;
        public static var m_catalog:Catalog = null;
        public static var m_tabbedCatalog:Catalog = null;
        public static var m_inventory:InventoryView = null;
        public static var m_collections:CollectionView = null;
        public static var m_storage:StorageView = null;
        private static var m_giftSellWindow:GiftSellDialog = null;
        private static var m_storageWindow:SlotDialog = null;
        private static var m_popupQueue:Array = [];
        private static var m_immediateDialogs:Array = [];
        private static var m_popupLock:int = 0;
        private static var m_currentDialog:Dialog;
        private static var m_frameLoadingDialog:FrameLoaderDialog = null;
        protected static var m_cursors:Array = [];
        protected static var m_currentCursor:Object = null;
        private static var m_buyableItemStr:String = "";
        private static var m_lastMarketEventItemName:String;
        protected static var m_franchiseMenu:FranchiseMenu;
        private static var m_isModalDialogOpen:Boolean = false;
        protected static var m_interruptedDialogs:Array = new Array();
        public static var m_vDlg:ValentineDialog;
        protected static var m_questManagerView:QuestManagerView = null;
        protected static var m_visitorDlg:VisitorCenterDialog;
        protected static var m_copsDlg:CopsDialog;
        protected static var m_peddlerMarketDlg:PeddlerMarketDialog;
        protected static var m_waitingPatrols:Array = new Array();
        protected static var m_municipalUpgradesDialog:MunicipalUpgradesDialog;
        protected static var m_munInventoryUpgradesDialog:MunInventoryUpgradesDialog;
        protected static var m_businessUpgradesDialog:BusinessUpgradesDialog;

        private const SEND_GIFT_TO:String = "sendGiftTo";
        private const SEND_GIFT:String = "sendGift";
        private const ADD_NEIGHBOR:String = "addNeighbor";
        private const VISIT_NEIGHBOR:String = "visitNeighbor";
        private const SEND_MESSAGE_NEIGHBOR:String = "sendMessageToNeighbor";
        private const WIDTH_MULTIPLIER:Number = 1.1;
        private const NEIGHBOR_ACTION_OFFSET_Y:int = -115;
        protected const DEFAULT_TOOL_TIP_APPEAR_TIME:Number = 0.5;
        protected const MIN_TOOL_TIP_APPEAR_TIME:Number = 0.1;
        protected const TOOLTIP_OFFSET_X:int = 5;

        public var m_initialWidth:int;
        public var m_initialHeight:int;
        public var m_friendBar:FriendBar;
        public var m_friendBarX:int;
        private var m_neighborBackground:Bitmap;
        private var m_actionMenuMode:String;
        private var m_clickedSlot:FriendBarSlot;
        public var m_bottomUI:Sprite;
        public var performanceTracker:PerformanceTracker;
        public var getCoinsButton:DisplayObject;
        protected var m_cursorId:int;
        public var m_takePhoto:GameSprite;
        public var m_home:GameSprite;
        private var m_buildMenu:BuildModeMenu;
        private var m_toasterManager:ToasterManager;
        private var m_lightboxOverlay:Sprite;
        private var m_overlaySWFs:Dictionary;
        private var m_settingsMenu:SettingsMenu;
        private var m_defaultModeButton:Sprite;
        private var m_franchiseModeButton:Sprite;
        private var m_buyModeButton:SpriteButton;
        private var m_giftModeButton:Sprite;
        private var m_selectedActionMode:String;
        public var m_expandedMenu:ExpandedMenu;
        private var m_bExpandedMenuOpen:Boolean = false;
        public var m_neighborActionsMenu:NeighborActionsMenu;
        public var m_friendWindow:JWindow;
        public var bNeighborActionsMenuOn:Boolean = false;
        protected var m_toolTip:ToolTipDialog = null;
        protected var m_toolTipTarget:IToolTipTarget = null;
        protected var m_tooltipTimer:Number;
        public var m_friendSprite:Sprite;
        protected var m_cityNameHolder:Sprite;
        protected var m_cityNameWindow:JWindow;
        public var m_cityNamePanel:CityNamePanel;
        protected var m_cityHappinessHolder:Sprite;
        protected var m_cityHappinessWindow:JWindow;
        protected var m_cityHappinessPanel:CityHappinessPanel;
        protected var neighborActionButtonMenu:NeighborVisitGiftHireMenu;
        protected var bNeighborButtonMenuOn:Boolean;
        protected var m_leftQuestIconLayer:Sprite;
        protected var m_rightQuestIconLayer:Sprite;
        private var m_hud:HUD;
        public var renameDialog:RenameDialog;

        public function UI():void{
            this.m_bottomUI = new Sprite();
            this.m_overlaySWFs = new Dictionary();
            this.m_leftQuestIconLayer = new Sprite();
            this.m_rightQuestIconLayer = new Sprite();
            super();
            Global.ui = this;
            AUTO_CLOSE_MARKET = true;
            this.m_initialWidth = Global.stage.stageWidth;
            this.m_initialHeight = Global.stage.stageHeight;
            this.m_friendSprite = new Sprite();
            this.m_settingsMenu = new SettingsMenu();
            this.m_settingsMenu.y = -30;
            this.m_settingsMenu.x = 698;
            this.m_settingsMenu.addEventListener(UIEvent.SETTINGS_TOGGLE_CLICK, this.settingsToggleClickHandler);
            this.m_friendSprite.addChild(this.m_settingsMenu);
            this.m_cityNameHolder = new Sprite();
            this.m_cityNameWindow = new JWindow(this.m_cityNameHolder);
            this.m_cityNameHolder.y = -36;
            this.m_cityNameHolder.x = 10;
            this.m_cityNamePanel = new CityNamePanel();
            this.m_cityNameWindow.setContentPane(this.m_cityNamePanel);
            this.m_cityNameWindow.show();
            this.m_cityNameHolder.addEventListener(MouseEvent.MOUSE_DOWN, this.blockCityName, false, 0, true);
            this.m_cityNameHolder.addEventListener(MouseEvent.MOUSE_MOVE, this.blockCityName, false, 0, true);
            ASwingHelper.prepare(this.m_cityNameWindow);
            this.m_friendSprite.addChild(this.m_cityNameHolder);
            this.m_toasterManager = new ToasterManager();
            this.m_toasterManager.x = 230;
            this.m_friendSprite.addChild(this.m_toasterManager);
            this.m_neighborBackground = new EmbeddedArt.hud_nghbr_background();
            this.m_neighborBackground.y = -38;
            this.m_neighborBackground.x = 0;
            this.m_friendSprite.addChild(this.m_neighborBackground);
            this.m_bottomUI.addEventListener(MouseEvent.MOUSE_DOWN, this.onMaskBitmapEvent, false, 0, true);
            this.m_bottomUI.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskBitmapEvent, false, 0, true);
            this.m_bottomUI.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskBitmapEvent, false, 0, true);
            this.m_bottomUI.addEventListener(MouseEvent.CLICK, this.onMaskBitmapEvent, false, 0, true);
            this.m_bottomUI.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver, false, 0, true);
            this.m_bottomUI.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut, false, 0, true);
            this.m_cityHappinessHolder = new Sprite();
            this.m_cityHappinessWindow = new JWindow(this.m_cityHappinessHolder);
            this.m_cityHappinessHolder.y = -38;
            this.m_cityHappinessHolder.x = 8;
            this.m_cityHappinessPanel = new CityHappinessPanel();
            this.m_cityHappinessWindow.setContentPane(this.m_cityHappinessPanel);
            this.m_cityHappinessWindow.show();
            this.m_cityHappinessHolder.mouseEnabled = (this.m_cityHappinessHolder.mouseChildren = false);
            ASwingHelper.prepare(this.m_cityHappinessWindow);
            this.m_friendSprite.addChild(this.m_cityHappinessHolder);
            this.createModeButtons();
            this.m_friendBar = new FriendBar();
            this.m_friendBar.addEventListener(FriendBarSlotEvent.FRIEND_BAR_SLOT_CLICK, this.onNeighborBarClick, false, 0, true);
            this.m_friendBar.addEventListener(FriendBarSlotEvent.FRIEND_BAR_SLOT_ROLLOVER, this.onNeighborBarRollover, false, 0, true);
            this.m_friendBar.addEventListener(FriendBarEvent.LOADED, this.onFriendBarLoaded, false, 0, true);
            this.m_friendSprite.addEventListener(MouseEvent.ROLL_OUT, this.removeNeighborActions, false, 0, true);
            this.m_bottomUI.addChild(this.m_friendSprite);
            this.m_friendSprite.y = 472;
            this.m_friendWindow = new JWindow(this.m_friendSprite);
            this.m_friendWindow.setActivable(false);
            this.m_friendWindow.setY(-4);
            this.m_friendWindow.setContentPane(this.m_friendBar);
            ASwingHelper.prepare(this.m_friendWindow);
            this.m_friendWindow.show();
            this.createQuickButtons();
            if (((Config.DEBUG_MODE) || (Game.DEBUG_PRODUCTION_OVERRIDE))){
                this.performanceTracker = new PerformanceTracker();
                addChild(this.performanceTracker);
                this.performanceTracker.visible = Config.DEBUG_MODE;
            };
            addChild(this.m_bottomUI);
            this.m_bottomUI.x = ((Global.stage.stageWidth - this.m_bottomUI.width) / 2);
            this.m_hud = new HUD(this.m_leftQuestIconLayer, this.m_rightQuestIconLayer);
            addChildAt(this.m_hud, 0);
            addChildAt(this.m_leftQuestIconLayer, 1);
            addChildAt(this.m_rightQuestIconLayer, 2);
            GlobalEngine.stage.addEventListener(Event.RESIZE, this.onResize);
            this.onResize(null);
            this.m_actionMenuMode = UIEvent.CURSOR;
            Global.stage.addEventListener(MouseEvent.CLICK, this.stageClickHandler);
            try {
                if (ExternalInterface.available){
                    ExternalInterface.addCallback("onFeaturePromo", onFeaturePromo);
                };
            } catch(err:Error) {
            };
        }
        public static function get currentPopup():Dialog{
            return (m_currentDialog);
        }
        public static function setCityName(_arg1:String):void{
            if (!_arg1){
                Global.ui.m_cityNamePanel.cityName = ZLoc.t("Main", "NameSuffix");
            } else {
                Global.ui.m_cityNamePanel.cityName = _arg1;
            };
        }
        public static function populateFriendBarData(_arg1:Array):void{
            var _local3:Friend;
            var _local7:Array;
            var _local8:Object;
            var _local9:Boolean;
            var _local10:Object;
            var _local11:String;
            var _local12:Player;
            var _local13:Dictionary;
            var _local14:String;
            var _local2:Array = [];
            var _local4 = 6;
            if (LocaleHelper.localSetting.sns.feature_xpromo){
                _local7 = Global.gameSettings.getXpromos();
                for each (_local8 in _local7) {
                    _local9 = InGameXPromoManager.checkXPromoGates(_local8);
                    if (_local9){
                        _local2.push(new XPromoFriend(_local8));
                        _local4--;
                        break;
                    };
                };
            };
            var _local5:Object = new Object();
            if (RealtimeManager.inExperiment){
                _local5 = ExternalInterface.call("getOnlineFriends");
            };
            var _local6:int;
            while (_local6 < _arg1.length) {
                _local10 = _arg1[_local6];
                _local11 = _local10.uid;
                _local12 = Global.player.findFriendById(_local11);
                if (_local12 != null){
                    _local13 = new Dictionary();
                    if (_local10.commodities){
                        for (_local14 in _local10.commodities.storage) {
                            _local13[_local14] = _local10.commodities.storage[_local14];
                        };
                    };
                    _local3 = new Friend(_local10.uid, _local10.gold, _local10.xp, _local10.level, _local10.firstTimeVisit, null, _local10.cityname, _local12.snUser.picture, _local12.snUser.firstName, _local13, _local10.socialLevel, false, false, _local10.rollCall, _local10.collect);
                    _local3.playerClassType = _local10.playerClassType;
                    if (((_local5) && (_local5[_local11]))){
                        _local3.m_online = true;
                    };
                    _local2.push(_local3);
                    Global.player.setFriendCityName(_local10.uid, _local10.cityname);
                    _local4--;
                    _local13 = null;
                };
                _local6++;
            };
            _local2.sortOn("xp", Array.NUMERIC, Array.DESCENDING);
            _local2.reverse();
            _local6 = 0;
            while (_local6 < _local4) {
                _local3 = new Friend(null, 0, 0, 0, false, null, "", null, null, null, 0, true, true);
                _local2.push(_local3);
                _local6++;
            };
            Global.friendbar = _local2;
        }
        public static function addToFriendBarData(_arg1:Object):void{
            var _local2:Friend;
            var _local4:Boolean;
            var _local5:Boolean;
            var _local6:String;
            var _local7:Player;
            var _local8:Dictionary;
            var _local9:String;
            var _local3:int;
            while (_local3 < Global.friendbar.length) {
                _local4 = (((_arg1.xp <= Global.friendbar[_local3].xp)) && (!(Global.friendbar[_local3].empty)));
                _local5 = (_local3 == (Global.friendbar.length - 1));
                if (((_local4) || (_local5))){
                    _local6 = _arg1.uid;
                    _local7 = Global.player.findFriendById(_local6);
                    if (_local7 != null){
                        _local8 = new Dictionary();
                        if (_arg1.commodities){
                            for (_local9 in _arg1.commodities.storage) {
                                _local8[_local9] = _arg1.commodities.storage[_local9];
                            };
                        };
                        _local2 = new Friend(_arg1.uid, _arg1.gold, _arg1.xp, _arg1.level, _arg1.firstTimeVisit, null, _arg1.cityname, _local7.snUser.picture, _local7.snUser.firstName, _local8, _arg1.socialLevel, false, false);
                        _local2.playerClassType = _arg1.playerClassType;
                        Global.friendbar.splice(_local3, 0, _local2);
                        Global.player.setFriendCityName(_arg1.uid, _arg1.cityname);
                        _local8 = null;
                        break;
                    };
                };
                _local3++;
            };
        }
        public static function populateNeighborsBar():void{
            var _local2:Array;
            var _local3:Friend;
            var _local4:int;
            var _local5:Boolean;
            var _local6:String;
            var _local7:Object;
            var _local1:Array = Global.player.unparsedNeighborsData;
            if (null != _local1){
                _local2 = [];
                _local4 = 0;
                while (_local4 < _local1.length) {
                    _local6 = _local1[_local4].uid;
                    if (Global.player.findFriendById(_local6) != null){
                        _local7 = _local1[_local4];
                        _local2.push(_local3);
                    };
                    _local4++;
                };
                _local2.sortOn("xp", Array.NUMERIC, Array.DESCENDING);
                _local2.reverse();
                _local4 = 0;
                while (_local4 < NUM_EMPTY_NEIGHBORS) {
                    _local2.push(_local3);
                    _local4++;
                };
                Global.friendbar = _local2;
                _local5 = (((0 == _local1.length)) || ((((_local1.length > 0)) && (Global.player.hasFriendsSNData()))));
                if (Global.ui){
                    Global.ui.m_friendBar.populateNeighbors(Global.friendbar, _local5);
                    Global.ui.setFriendBarPos(Math.max((Global.friendbar.length - 15), 0));
                };
                if (_local5){
                    Global.player.unparsedNeighborsData = null;
                };
            };
        }
        public static function confirmAddNeighbor():void{
            var _local2:String;
            var _local1:DisplayObject = Global.stage.getChildByName("reserveLotPopup");
            if (_local1 == null){
                _local2 = ZLoc.t("Main", "ReserveLot");
                UI.displayPopup(new GenericDialog(_local2, "Confirm", GenericDialogView.TYPE_YESNO, onConfirmReserve), true, "reserveLotPopup", true);
            };
        }
        protected static function onConfirmReserve(_arg1:GenericPopupEvent):void{
            if (_arg1.button == GenericPopup.YES){
                GlobalEngine.socialNetwork.redirect("invite.php?ref=neighborsInvitePage");
            };
        }
        public static function visitNeighbor(_arg1:String):void{
            GameTransactionManager.addTransaction(new TGetVisitMission(_arg1), true);
        }
        public static function displaySupplies(_arg1:String):SuppliesDialog{
            var _local2:SuppliesDialog = new SuppliesDialog("", "Supplies", _arg1);
            UI.displayPopup(_local2);
            return (_local2);
        }
        public static function displayFTUEDialog(_arg1:String, _arg2:String, _arg3:int=0, _arg4:Function=null, _arg5:String="", _arg6:Boolean=false, _arg7:String=null):GenericDialog{
            var _local8:GuideDialog = new GuideDialog(_arg1, _arg2, "next");
            _local8.name = _arg5;
            if (_arg6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local8);
                    _local8.show();
                } else {
                    m_popupQueue.splice(0, 0, _local8);
                };
            } else {
                UI.displayPopup(_local8);
            };
            return (_local8);
        }
        public static function displayNewsFlash(_arg1:String, _arg2:int=0, _arg3:String="", _arg4:String="", _arg5:String="", _arg6:Boolean=false, _arg7:String=null):GenericDialog{
            var _local8:NewsFlashDialog = new NewsFlashDialog(_arg1, _arg5, _arg4, _arg3, _arg2, onNewsFlashClosed);
            _local8.name = _arg5;
            if (_arg6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local8);
                    _local8.show();
                } else {
                    m_popupQueue.splice(0, 0, _local8);
                };
            } else {
                UI.displayPopup(_local8);
            };
            return (_local8);
        }
        protected static function onNewsFlashClosed(_arg1:GenericPopupEvent):void{
            _arg1.target.removeEventListener(GenericPopupEvent.SELECTED, onNewsFlashClosed);
            if (_arg1.button != GenericPopup.YES){
                return;
            };
            Global.world.viralMgr.sendNewsViralFeed(Global.player, NewsFlashDialog.GetLastNewsTitle(), NewsFlashDialog.GetLastNewsSubhead(), NewsFlashDialog.GetLastNewsMessage());
        }
        public static function displayCreditBasic(_arg1:Boolean=false):GenericDialog{
            var _local2:String;
            var _local3:GenericDialog;
            var _local4:String;
            if (!_arg1){
                _local2 = ZLoc.t("Dialogs", "CreditDialog1_message");
                _local3 = new CreditDialog(_local2, "CreditDialog1", GenericDialogView.TYPE_PLAY, onCreditBasicClose, "CreditDialog1");
                _local3.name = "CreditDialog1";
            } else {
                _local2 = ZLoc.t("Dialogs", "CreditDialog2_message");
                _local3 = new CreditDialog(_local2, "CreditDialog2", GenericDialogView.TYPE_PLAY, onCreditBasicClose, "CreditDialog2");
                _local3.name = "CreditDialog2";
            };
            _local4 = _local3.name;
            UI.displayPopup(_local3, true, _local4, true);
            return (_local3);
        }
        private static function onCreditBasicClose(_arg1:GenericPopupEvent):void{
            GameTransactionManager.addTransaction(new TClearCompensationFlag());
        }
        private static function onImmediateDialogClose(_arg1:Event):void{
            var _local2:int = m_immediateDialogs.indexOf(_arg1.target);
            if (_local2 >= 0){
                m_immediateDialogs.splice(_local2, 1);
            };
        }
        public static function displayMessage(_arg1:String, _arg2:int=0, _arg3:Function=null, _arg4:String="", _arg5:Boolean=false, _arg6:String=null, _arg7:String="", _arg8:int=0, _arg9:Boolean=false):GenericDialog{
            var _local10:GenericDialog = new GenericDialog(_arg1, _arg4, _arg2, _arg3, _arg7, _arg6, true, _arg8, "", null, "", true, _arg9);
            _local10.name = _arg4;
            if (_arg5){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local10);
                    _local10.show();
                    m_immediateDialogs.push(_local10);
                    _local10.addEventListener(Event.CLOSE, onImmediateDialogClose);
                } else {
                    m_popupQueue.splice(0, 0, _local10);
                };
            } else {
                UI.displayPopup(_local10, true, _arg4, true);
            };
            return (_local10);
        }
        public static function displayDonationMessage(_arg1:String, _arg2:String, _arg3:int=0, _arg4:Function=null, _arg5:String="", _arg6:Boolean=false, _arg7:String=null, _arg8:String="", _arg9:int=0, _arg10:int=5):GenericDialog{
            var _local11:PotatoDonationDialog = new PotatoDonationDialog(_arg1, _arg5, _arg3, _arg4, _arg8, _arg7, true, _arg9, "Purchase", _arg2, _arg10);
            _local11.name = _arg5;
            if (_arg6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local11);
                    _local11.show();
                } else {
                    m_popupQueue.splice(0, 0, _local11);
                };
            } else {
                UI.displayPopup(_local11, true, _arg5, true);
            };
            return (_local11);
        }
        public static function displayMessageWithBold(_arg1:String, _arg2:String, _arg3:int=0, _arg4:Function=null, _arg5:String="", _arg6:Boolean=false, _arg7:String=null, _arg8:String="", _arg9:int=0):GenericDialog{
            var _local10:GenericDialogWithBold = new GenericDialogWithBold(_arg1, _arg2, _arg5, _arg3, _arg4, _arg8, _arg7, true, _arg9);
            _local10.name = _arg5;
            if (_arg6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local10);
                    _local10.show();
                } else {
                    m_popupQueue.splice(0, 0, _local10);
                };
            } else {
                UI.displayPopup(_local10, true, _arg5, true);
            };
            return (_local10);
        }
        public static function goToCashPage(_arg1:GenericPopupEvent):void{
            if (_arg1.button == GenericDialogView.YES){
                StatsManager.count("fv_cash_buy_fail", "click_yes_please");
                StatsManager.sendStats(true);
                FrameManager.navigateTo("money.php?ref=tab");
            };
        }
        public static function displayItemPurchaseConfirm(_arg1:Function, _arg2:Item, _arg3:Boolean=true, _arg4:Function=null, _arg5:Boolean=false, _arg6:String="default", _arg7:String="default", _arg8:String="default", _arg9:String="default"):GenericDialog{
            var _local12:ItemUnlockDialog;
            var _local10:Boolean;
            var _local11:String = Global.gameSettings.getImageByName(_arg2.name, "icon");
            var _local13:Function = UI.goToCashPage;
            if (_arg4 != null){
                _local13 = _arg4;
            };
            var _local14:int = GenericDialogView.TYPE_YESNO;
            var _local15:int = GenericDialogView.TYPE_GETCASH;
            if (((_arg5) && (_arg2.unlockShareFunc))){
                _local14 = GenericDialogView.TYPE_YESNO_SHARE;
                _local15 = GenericDialogView.TYPE_GETCASH_SHARE;
            };
            if (_arg3){
                _arg9 = ((_arg9)=="default") ? "ConfirmPurchase" : _arg9;
                _arg8 = ((_arg8)=="default") ? ZLoc.t("Dialogs", "ConfirmPurchaseMsg", {itemName:_arg2.localizedName}) : _arg8;
                _local12 = new ItemUnlockDialog(_arg8, "confirmPurchase", _local14, _arg1, _arg9, _local11, true, 0, "", null, _arg2);
            } else {
                _arg7 = ((_arg7)=="default") ? "ConfirmPurchaseFail" : _arg7;
                _arg6 = ((_arg6)=="default") ? ZLoc.t("Dialogs", "ConfirmPurchaseFailMsg", {itemName:_arg2.localizedName}) : _arg6;
                _local12 = new ItemUnlockDialog(_arg6, "confirmPurchase", _local15, _local13, _arg7, _local11, true, 0, "", null, _arg2);
            };
            _local12.name = "confirmPurchase";
            if (_local10){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local12);
                    _local12.show();
                } else {
                    m_popupQueue.splice(0, 0, _local12);
                };
            } else {
                UI.displayPopup(_local12, true, "unlockItem", true);
            };
            return (_local12);
        }
        public static function displayItemUnlock(_arg1:Function, _arg2:Item, _arg3:Boolean=true, _arg4:Function=null, _arg5:Boolean=false):GenericDialog{
            var _local8:ItemUnlockDialog;
            var _local6:Boolean;
            var _local7:String = Global.gameSettings.getImageByName(_arg2.name, "icon");
            var _local9:Function = UI.goToCashPage;
            if (_arg4 != null){
                _local9 = _arg4;
            };
            var _local10:int = GenericDialogView.TYPE_YESNO;
            var _local11:int = GenericDialogView.TYPE_GETCASH;
            if (((_arg5) && (_arg2.unlockShareFunc))){
                _local10 = GenericDialogView.TYPE_YESNO_SHARE;
                _local11 = GenericDialogView.TYPE_GETCASH_SHARE;
            };
            if (_arg3){
                if (LocaleHelper.localSetting.sns.cash_enable){
                    _local8 = new ItemUnlockDialog(ZLoc.t("Dialogs", "UnlockCashQuestion", {object:_arg2.localizedName}), "unlockItem", _local10, _arg1, "unlockItem", _local7, true, 0, "", null, _arg2);
                } else {
                    return (null);
                };
            } else {
                _local8 = new ItemUnlockDialog(ZLoc.t("Dialogs", "UnlockItemQuestion", {object:_arg2.localizedName}), "unlockItem", _local11, _local9, "unlockItem", _local7, true, 0, "", null, _arg2);
            };
            _local8.name = "unlockItem";
            if (_local6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local8);
                    _local8.show();
                } else {
                    m_popupQueue.splice(0, 0, _local8);
                };
            } else {
                UI.displayPopup(_local8, true, "unlockItem", true);
            };
            return (_local8);
        }
        public static function displayViralShareMessage(_arg1:String, _arg2:String, _arg3:int=0, _arg4:Function=null, _arg5:String="", _arg6:Boolean=false, _arg7:String=null, _arg8:String="", _arg9:int=0, _arg10:String="", _arg11:Boolean=true, _arg12:Boolean=false):GenericDialog{
            var _local13:GenericDialog = new GenericDialog(_arg2, _arg5, _arg3, _arg4, _arg8, _arg7, true, _arg9, _arg1, null, _arg10, _arg11, _arg12);
            _local13.name = _arg5;
            if (_arg6){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local13);
                    _local13.show();
                } else {
                    m_popupQueue.splice(0, 0, _local13);
                };
            } else {
                UI.displayPopup(_local13, true, _arg5, true);
            };
            return (_local13);
        }
        public static function displayValRewardsMessage(_arg1:String, _arg2:int=0, _arg3:Function=null, _arg4:String="", _arg5:Boolean=false, _arg6:String=null, _arg7:String="", _arg8:int=0):GenericDialog{
            var _local9:ValentinesDayRewardDialog = new ValentinesDayRewardDialog(_arg1, _arg4, _arg2, _arg3, _arg7, _arg6, true, _arg8, "");
            _local9.name = _arg4;
            if (_arg5){
                if (!UI.isScreenFrozen()){
                    Global.stage.addChild(_local9);
                    _local9.show();
                } else {
                    m_popupQueue.splice(0, 0, _local9);
                };
            } else {
                UI.displayPopup(_local9, true, _arg4, true);
            };
            return (_local9);
        }
        public static function displayStatus(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Object="", _arg5:Array=null, _arg6:Number=1.5, _arg7:int=32, _arg8:int=16, _arg9:Number=60, _arg10:Object=0xFFFFFF):void{
            var spr:* = null;
            var statusText:* = null;
            var iconLoader:* = null;
            var message:* = _arg1;
            var screenX:* = _arg2;
            var screenY:* = _arg3;
            var icon:String = _arg4;
            var iconFilters = _arg5;
            var tweenDuration:Number = _arg6;
            var tweenDisplacement:int = _arg7;
            var fontSize:int = _arg8;
            var iconSize:int = _arg9;
            var msgColor:int = _arg10;
            var addIcon:* = function (_arg1:DisplayObject):void{
                _arg1 = Utilities.getSmoothableBitmap(_arg1);
                if (message != ""){
                    _arg1.x = ((statusText.x - _arg1.width) - 5);
                } else {
                    _arg1.x = (-(_arg1.width) / 2);
                };
                _arg1.y = (statusText.y + ((statusText.height - _arg1.height) / 2));
                if (iconFilters != null){
                    _arg1.filters = iconFilters;
                };
                spr.addChild(_arg1);
            };
            spr = new Sprite();
            spr.x = screenX;
            spr.y = screenY;
            spr.mouseEnabled = false;
            spr.mouseChildren = false;
            statusText = new StrokeTextField(0x202020, 0.8);
            statusText.embedFonts = true;
            var resource_fmt:* = new TextFormat(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, fontSize, null, true);
            resource_fmt.color = msgColor;
            statusText.defaultTextFormat = resource_fmt;
            statusText.toolTipText = message;
            statusText.x = (-(statusText.textWidth) / 2);
            spr.addChild(statusText);
            Global.stage.addChild(spr);
            tweenStatusObject(spr, tweenDuration, tweenDisplacement);
            var iconUrl:* = (icon as String);
            if (((iconUrl) && (!((iconUrl == ""))))){
                iconLoader = LoadingManager.load(iconUrl, function (_arg1:Event):void{
                    if (((iconLoader) && (iconLoader.content))){
                        addIcon(iconLoader.content);
                    };
                });
            } else {
                if ((icon is DisplayObject)){
                    addIcon((icon as DisplayObject));
                };
            };
        }
        public static function displayStatusComponent(_arg1:DisplayObject, _arg2:Number, _arg3:Number, _arg4:Number=1.5, _arg5:int=32):void{
            _arg1.x = (_arg2 - (_arg1.width / 2));
            _arg1.y = _arg3;
            _arg1.alpha = 1;
            _arg1.visible = true;
            if ((_arg1 is DisplayObjectContainer)){
                (_arg1 as DisplayObjectContainer).mouseEnabled = false;
                (_arg1 as DisplayObjectContainer).mouseChildren = false;
            };
            Global.stage.addChild(_arg1);
            tweenStatusObject(_arg1, _arg4, _arg5);
        }
        private static function tweenStatusObject(_arg1:DisplayObject, _arg2:Number, _arg3:int):void{
            var dispObj:* = _arg1;
            var duration:* = _arg2;
            var displacement:* = _arg3;
            var readabilityDelay:* = 0.1;
            var remainingDuration:* = (duration - readabilityDelay);
            TweenLite.to(dispObj, remainingDuration, {
                delay:readabilityDelay,
                alpha:0.2,
                ease:Quadratic.easeIn
            });
            TweenLite.to(dispObj, remainingDuration, {
                delay:readabilityDelay,
                overwrite:0,
                y:(dispObj.y - displacement),
                onComplete:function ():void{
                    if (dispObj.parent){
                        dispObj.parent.removeChild(dispObj);
                    };
                }
            });
        }
        public static function displayPopup(_arg1:DisplayObject, _arg2:Boolean=true, _arg3:String="", _arg4:Boolean=false):void{
            _arg1.name = _arg3;
            if (_arg2){
                _arg2 = true;
                if (((_arg4) && (!((_arg3 == ""))))){
                    _arg2 = !(isPopupDuplicated(_arg3));
                };
                if (_arg2){
                    m_popupQueue.push(_arg1);
                };
                pumpPopupQueue();
            } else {
                if (!UI.isScreenFrozen()){
                    if (!isPopupDuplicated(_arg3)){
                        if (m_currentDialog){
                            m_interruptedDialogs.push(m_currentDialog);
                        };
                        popupOpen(_arg1);
                    };
                } else {
                    m_popupQueue.splice(0, 0, (_arg1 as Dialog));
                };
            };
        }
        public static function isPopupDuplicated(_arg1:String):Boolean{
            if (m_currentDialog){
                if (m_currentDialog.name == _arg1){
                    return (true);
                };
            };
            var _local2:int;
            while (_local2 < m_popupQueue.length) {
                if (m_popupQueue[_local2].name == _arg1){
                    return (true);
                };
                _local2++;
            };
            return (false);
        }
        public static function flushDialogs():void{
            if (m_currentDialog){
                m_currentDialog.close();
                m_currentDialog.removeEventListener(Event.CLOSE, onPopupClosed);
                m_currentDialog = null;
            };
            while (m_popupQueue.length) {
                m_currentDialog = m_popupQueue.pop();
                m_currentDialog.close();
                m_currentDialog.removeEventListener(Event.CLOSE, onPopupClosed);
                m_currentDialog = null;
            };
            while (m_immediateDialogs.length) {
                m_currentDialog = (m_immediateDialogs.pop() as Dialog);
                m_currentDialog.close();
                m_currentDialog.removeEventListener(Event.CLOSE, onPopupClosed);
                m_currentDialog = null;
            };
        }
        protected static function onPopupClosed(_arg1:Event):void{
            var _local2:Dialog;
            while (((m_interruptedDialogs) && ((m_interruptedDialogs.length > 0)))) {
                _local2 = m_interruptedDialogs.shift();
                if (_local2.isShown){
                    break;
                };
            };
            m_currentDialog = _local2;
            m_isModalDialogOpen = false;
            _arg1.currentTarget.removeEventListener(Event.CLOSE, onPopupClosed);
            pumpPopupQueue();
        }
        public static function pumpPopupQueue():void{
            var _local1:Dialog;
            var _local2:int;
            if (((((m_popupQueue.length) && ((m_currentDialog == null)))) && (InitializationManager.getInstance().haveAllCompleted()))){
                _local2 = 0;
                while (_local2 < m_popupQueue.length) {
                    _local1 = m_popupQueue[_local2];
                    if (((_local1.isLockable()) && ((UI.m_popupLock > 0)))){
                    } else {
                        if (_local1){
                            m_popupQueue.splice(_local2, 1);
                            if ((((Global.isVisiting() == true)) && ((_local1 is GiftNotify)))){
                            } else {
                                popupOpen(_local1);
                                break;
                            };
                        };
                    };
                    _local2++;
                };
            };
        }
        private static function popupOpen(_arg1:DisplayObject):void{
            var _local2:Dialog = (_arg1 as Dialog);
            if (_local2){
                _arg1.addEventListener(Event.CLOSE, onPopupClosed, false, 0, true);
                Global.stage.addChild(_arg1);
                m_currentDialog = _local2;
                if (m_currentDialog.isModal){
                    m_isModalDialogOpen = true;
                };
                m_currentDialog.show();
            };
        }
        public static function popupLock():void{
            m_popupLock++;
        }
        public static function popupUnlock():void{
            m_popupLock--;
            if (m_popupLock <= 0){
                pumpPopupQueue();
                m_popupLock = 0;
            };
        }
        public static function displayMenu(_arg1:Array, _arg2:Function, _arg3:Boolean=false, _arg4:Point=null):void{
            var _local5:ContextMenu;
            var _local6:Number;
            if ((((Global.isVisiting() == false)) || (_arg3))){
                _local5 = new ContextMenu(_arg1);
                _local5.addEventListener(MouseEvent.CLICK, _arg2);
                if (_arg4 == null){
                    _arg4 = new Point(Global.stage.mouseX, Global.stage.mouseY);
                };
                _local6 = Math.min(_arg4.y, ((Global.stage.stageHeight - _local5.height) - SCREEN_MENU_BUFFER));
                _local5.show(_arg4.x, _local6);
            };
        }
        public static function isScreenFrozen():Boolean{
            return (m_isFreezing);
        }
        public static function freezeScreen(_arg1:Boolean=false, _arg2:Boolean=false, _arg3:String=null):void{
            var _local4:Stage;
            var _local5:String;
            if (m_isFreezing == false){
                _local4 = Global.stage;
                m_isFreezing = true;
                _local4.mouseChildren = false;
                if (Global.stage.displayState == StageDisplayState.FULL_SCREEN){
                    Global.stage.displayState = StageDisplayState.NORMAL;
                };
                if (_arg1 == true){
                    _local5 = (_arg3) ? _arg3 : "FrameLoading";
                    m_frameLoadingDialog = new FrameLoaderDialog(ZLoc.t("Dialogs", _local5), null);
                    m_frameLoadingDialog.setupDefaultSizeAndPosition();
                };
                m_frozenGrayRect = new Shape();
                m_frozenGrayRect.graphics.beginFill(0, 0.5);
                m_frozenGrayRect.graphics.moveTo(-10000, -10000);
                m_frozenGrayRect.graphics.lineTo(10000, -10000);
                m_frozenGrayRect.graphics.lineTo(10000, 10000);
                m_frozenGrayRect.graphics.lineTo(-10000, 10000);
                m_frozenGrayRect.graphics.endFill();
                _local4.addChild(m_frozenGrayRect);
                if (_arg1 == true){
                    _local4.addChild(m_frameLoadingDialog);
                };
                Sounds.stopAnyLoopingSounds();
            };
        }
        public static function thawScreen():void{
            var _local1:Stage;
            var _local2:DisplayObject;
            var _local3:Boolean;
            if (m_isFreezing){
                _local1 = Global.stage;
                m_isFreezing = false;
                _local1.mouseChildren = true;
                if (m_frameLoadingDialog != null){
                    m_frameLoadingDialog.close();
                    m_frameLoadingDialog = null;
                };
                if (((!((m_frozenGrayRect == null))) && ((m_frozenGrayRect.parent == _local1)))){
                    _local1.removeChild(m_frozenGrayRect);
                };
                m_frozenGrayRect = null;
                _local2 = Global.stage.getChildByName("root1");
                if (_local2){
                    _local1.setChildIndex(_local2, 0);
                };
                if (m_currentDialog){
                    _local1.setChildIndex(m_currentDialog, (_local1.numChildren - 1));
                };
                InputManager.enableInput();
                Global.ui.mouseEnabled = true;
                Global.ui.mouseChildren = true;
                pumpPopupQueue();
            };
        }
        public static function onStageMouseMove(_arg1:MouseEvent):void{
            if (((m_currentCursor) && (m_currentCursor.displayObj))){
                m_currentCursor.displayObj.x = (Global.stage.mouseX + CURSOR_OFFSET_X);
                m_currentCursor.displayObj.y = (Global.stage.mouseY + CURSOR_OFFSET_Y);
            };
        }
        public static function hasCursor(_arg1:int):Boolean{
            var _local4:Object;
            var _local2:Boolean;
            var _local3:int;
            while (_local3 < m_cursors.length) {
                _local4 = m_cursors[_local3];
                if (_local4.id == _arg1){
                    _local2 = true;
                    break;
                };
                _local3++;
            };
            return (_local2);
        }
        public static function setCursor(_arg1:Object, _arg2:Boolean=false):int{
            var _local3:DisplayObject;
            var _local6:Number;
            if ((_arg1 is DisplayObject)){
                _local3 = (_arg1 as DisplayObject);
            } else {
                if ((_arg1 is Class)){
                    _local3 = new (_arg1)();
                };
            };
            var _local4:int = Constants.INDEX_NONE;
            var _local5:Object = {
                displayObj:_local3,
                id:Utilities.generateUniqueId(),
                keepSystemCursor:_arg2
            };
            if (_local3){
                _local6 = 0;
                _local6 = Math.min(1, (MAX_CURSOR_SIZE / _local3.width), (MAX_CURSOR_SIZE / _local3.height));
                _local3.scaleX = (_local3.scaleY = _local6);
                if ((_local3 is Bitmap)){
                    (_local3 as Bitmap).smoothing = true;
                };
                _local3.filters = [new GlowFilter(0, 0.5, 1, 1, 16, BitmapFilterQuality.HIGH)];
            };
            m_cursors.push(_local5);
            updateCurrentCursor();
            _local4 = _local5.id;
            return (_local4);
        }
        public static function removeCursor(_arg1:int):void{
            var _local3:Object;
            var _local2:int;
            while (_local2 < m_cursors.length) {
                _local3 = m_cursors[_local2];
                if (_local3.id == _arg1){
                    m_cursors.splice(_local2, 1);
                    break;
                };
                _local2++;
            };
            updateCurrentCursor();
        }
        public static function removeAllCursors():void{
            m_cursors = [];
            updateCurrentCursor();
        }
        public static function updateCurrentCursor(_arg1:Boolean=false):void{
            var _local2:Object;
            if (m_cursors.length){
                _local2 = m_cursors[(m_cursors.length - 1)];
                if (((_local2.keepSystemCursor) || ((_local2.displayObj == null)))){
                    Mouse.show();
                } else {
                    Mouse.hide();
                };
            } else {
                Mouse.show();
            };
            if (((!((_local2 == m_currentCursor))) || (_arg1))){
                if (((m_currentCursor) && (m_currentCursor.displayObj))){
                    m_currentCursor.displayObj.parent.removeChild(m_currentCursor.displayObj);
                };
                m_currentCursor = _local2;
                if (((m_currentCursor) && (m_currentCursor.displayObj))){
                    m_currentCursor.displayObj.x = (Global.stage.mouseX + CURSOR_OFFSET_X);
                    m_currentCursor.displayObj.y = (Global.stage.mouseY + CURSOR_OFFSET_Y);
                    Global.stage.addChild(m_currentCursor.displayObj);
                };
            };
        }
        public static function goHome():void{
            Global.ui.m_home.visible = false;
            Global.setVisiting(null);
            m_catalog = null;
            if (((Global.player) && ((Global.player.getId() > 0)))){
                GameTransactionManager.addTransaction(new TWorldLoad(Global.player.uid), true, true);
            };
        }
        protected static function getNewLevelItems(_arg1:int, _arg2:Array, _arg3:Array, _arg4:Array):void{
            var _local7:XML;
            var _local5:XMLList = Global.gameSettings.getItems();
            var _local6:int;
            while (_local6 < _local5.length()) {
                _local7 = _local5[_local6];
                if (((_local7.requiredLevel) && ((_local7.requiredLevel == _arg1)))){
                    if ((((((_local7.@buyable == "true")) && ((_local7.descendants("limitedEnd").length() == 0)))) && (!((_local7.@levelUpDisplay == "false"))))){
                        _arg3.push(_local7.@name);
                    };
                };
                if (((_local7.requiredLevel) && ((_local7.requiredLevel == (_arg1 + 1))))){
                    if ((((((_local7.@buyable == "true")) && ((_local7.descendants("limitedEnd").length() == 0)))) && (!((_local7.@levelUpDisplay == "false"))))){
                        _arg2.push(Global.gameSettings.getItemFriendlyName(_local7.@name));
                    };
                };
                _local6++;
            };
        }
        protected static function getNewLevelItemsXML(_arg1:int, _arg2:Array, _arg3:Array):void{
            var _local6:XML;
            var _local4:XMLList = Global.gameSettings.getItems();
            var _local5:int;
            while (_local5 < _local4.length()) {
                _local6 = _local4[_local5];
                if (((_local6.requiredLevel) && ((_local6.requiredLevel == _arg1)))){
                    if ((((((_local6.@buyable == "true")) && ((_local6.descendants("limitedEnd").length() == 0)))) && (!((_local6.@levelUpDisplay == "false"))))){
                        _arg3.push(_local6.@name);
                    };
                    if (_local6.@giftable == "true"){
                        _arg2.push(_local6.@name);
                    };
                };
                _local5++;
            };
        }
        public static function displayLevelUpDialog(_arg1:int):void{
            var _local10:Object;
            var _local11:GenericDialog;
            var _local2:Array = [];
            var _local3:Array = [];
            var _local4:Array = [];
            var _local5:Array = [];
            getNewLevelItems(_arg1, _local4, _local3, _local5);
            var _local6:String = ZLoc.t("Levels", ("Level" + _arg1));
            var _local7:LevelUpDialog = new LevelUpDialog(_arg1, _local3, _local4, _local5);
            displayPopup(_local7);
            _local7.view.addEventListener(GenericPopupEvent.SELECTED, onLevelUpClosed);
            var _local8:XML = Global.gameSettings.getLevelXML(_arg1);
            var _local9:String = _local8.@notes;
            if (_local9 != ""){
                _local10 = Utilities.parseLocalizationString(_local9);
                _local11 = new GenericDialog(ZLoc.t(_local10.filename, _local10.stringname), "", 0, null, "", "", true);
                displayPopup(_local11);
            };
        }
        protected static function onLevelUpClosed(_arg1:GenericPopupEvent):void{
            _arg1.target.removeEventListener(GenericPopupEvent.SELECTED, onLevelUpClosed);
            var _local2:int = Global.player.level;
            if (_local2 == 2){
                if (LocaleHelper.localSetting.sns.feature_xpromo){
                    displayInviteFarmFriendsDialog();
                };
            };
        }
        public static function displaySocialLevelUpDialog(_arg1:int):void{
            var _local4:GenericDialog;
            var _local2:Array = [];
            var _local3:Array = [];
            var _local5:XML = Global.gameSettings.getReputationLevelXML(_arg1);
            var _local6:int = ((_local5)!=null) ? int(_local5.@reward) : 0;
            _local4 = new SocialLevelUpDialog(_arg1, _local6, onSocialLevelUpClosed);
            Global.player.commodities.add(Commodities.GOODS_COMMODITY, _local6);
            UI.displayPopup(_local4, true, "", true);
        }
        protected static function onSocialLevelUpClosed(_arg1:GenericPopupEvent):void{
            _arg1.target.removeEventListener(GenericPopupEvent.SELECTED, onSocialLevelUpClosed);
            if (_arg1.button != GenericPopup.YES){
                return;
            };
            Global.world.viralMgr.sendReputationUpFeed(Global.player, Global.player.socialLevel);
        }
        public static function displayInviteFarmFriendsDialog():void{
            var _local1:String;
            var _local3:String;
            var _local5:Function;
            var _local2:String = ZLoc.t("Dialogs", "IdleFarmFriends_text");
            var _local4 = "assets/dialogs/inviteFarmFriends_farmFriends.png";
            var _local6:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_EMAIL_FARMVILLE_FRIENDS);
            if (_local6 == ExperimentDefinitions.EMAIL_FARMVILLE_FRIENDS){
                _local1 = ZLoc.t("Dialogs", "IdleFarmFriends_emailTitle");
                _local3 = "IdleFarmFriends_emailButton";
                _local5 = UI.emailFarmFriendsCallback;
            } else {
                _local1 = ZLoc.t("Dialogs", "IdleFarmFriends_inviteTitle");
                _local3 = "IdleFarmFriends_inviteButton";
                _local5 = UI.inviteFarmFriendsCallback;
            };
            var _local7:GenericDialog = new GenericPictureDialog(_local2, "IdleFarmFriends", GenericDialogView.TYPE_OK, _local5, _local1, "", true, 0, _local3, _local4);
            displayPopup(_local7);
            StatsManager.milestone("add_farm_friends");
        }
        public static function emailFarmFriendsCallback(_arg1:GenericPopupEvent):void{
            var _local2:TEmailFarmFriends;
            if (_arg1.button == GenericPopup.YES){
                _local2 = new TEmailFarmFriends();
                GameTransactionManager.addTransaction(_local2);
                displayFarmFriendsConfirmDialog();
            };
        }
        public static function inviteFarmFriendsCallback(_arg1:GenericPopupEvent):void{
            if (_arg1.button == GenericPopup.YES){
                redirectToInvitePage("invite_farmville_friends", "farmville", UI.displayFarmFriendsConfirmDialog);
            };
        }
        public static function displayFarmFriendsConfirmDialog(_arg1:Boolean=true):void{
            var _local2:String;
            var _local3:String;
            var _local4:String;
            var _local5:Function;
            var _local6:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_EMAIL_FARMVILLE_FRIENDS);
            if (_local6 == ExperimentDefinitions.EMAIL_FARMVILLE_FRIENDS){
                _local2 = "IdleFarmFriendsConfirmEmail";
                _local3 = ZLoc.t("Dialogs", "IdleFarmFriendsConfirm_emailText");
                _local4 = "IdleFarmFriendsConfirm_emailButton";
                _local5 = UI.emailFarmFriendsPostDialog;
            } else {
                _local2 = "IdleFarmFriendsConfirmInvite";
                _local3 = ZLoc.t("Dialogs", "IdleFarmFriendsConfirm_inviteText");
                _local4 = "IdleFarmFriendsConfirm_inviteButton";
                _local5 = UI.inviteFarmFriendsPostDialog;
            };
            var _local7:GenericDialog = new SamAdviceDialog(_local3, _local2, 0, _local5, _local2, "", true, 0, _local4);
            displayPopup(_local7);
        }
        public static function emailFarmFriendsPostDialog(_arg1:GenericPopupEvent):void{
            if (_arg1.button == GenericPopup.YES){
                redirectToInvitePage("invite_farmville_friends");
            };
        }
        public static function inviteFarmFriendsPostDialog(_arg1:GenericPopupEvent):void{
            var _local2:TEmailFarmFriends;
            if (_arg1.button == GenericPopup.YES){
                _local2 = new TEmailFarmFriends();
                GameTransactionManager.addTransaction(_local2);
            };
        }
        public static function pushNewItems(_arg1:GenericPopupEvent):void{
            var _local2:int;
            var _local3:Array;
            var _local4:Array;
            _arg1.target.removeEventListener(GenericPopupEvent.SELECTED, pushNewItems);
            if (_arg1.button == GenericPopup.ACCEPT){
                _local2 = Global.player.level;
                _local3 = [];
                _local4 = [];
                getNewLevelItemsXML(_local2, _local3, _local4);
                displayMiniMarketDialog(_local4, "motd", "tool");
            };
        }
        public static function resolveIfAssetsHaveNotLoaded(_arg1:String):Boolean{
            var _local2:Number;
            var _local3:Number;
            if (!Global.delayedAssets.isAssetLoaded(_arg1)){
                _local2 = Global.ui.mouseX;
                _local3 = Global.ui.mouseY;
                displayStatus(ZLoc.t("Dialogs", "AssetsLoading"), _local2, _local3);
                return (true);
            };
            return (false);
        }
        public static function clearTabbedCatalog():void{
            if (m_tabbedCatalog == null){
                return;
            };
            m_tabbedCatalog.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
            m_tabbedCatalog.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
            m_tabbedCatalog.removeEventListener(CloseEvent.CLOSE, onCatalogClose);
            m_tabbedCatalog.close();
            Global.ui.bottomUI.removeChild(m_tabbedCatalog);
            m_tabbedCatalog = null;
        }
        public static function displayTabbedCatalog(_arg1:TabbedCatalogUI, _arg2:String, _arg3:String=null, _arg4:Array=null, _arg5:String="", _arg6:Boolean=false, _arg7:Boolean=false):Catalog{
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.MARKET_ASSETS)){
                return (null);
            };
            if (_arg2 == "close"){
                if (((m_tabbedCatalog) && (m_tabbedCatalog.parent))){
                    m_tabbedCatalog.close();
                };
            };
            if (_arg2 != "close"){
                Global.marketSessionTracker.startSession();
                if (m_tabbedCatalog == null){
                    m_tabbedCatalog = new TabbedCatalog(_arg2, _arg1, _arg3, _arg4, _arg5, _arg6);
                } else {
                    if (m_tabbedCatalog != null){
                        if (_arg7){
                            m_tabbedCatalog.showArrow();
                        };
                        if (_arg2 != null){
                            m_tabbedCatalog.type = _arg2;
                        };
                        if (_arg3 != null){
                            m_tabbedCatalog.item = _arg3;
                        };
                        if (_arg5 != ""){
                            m_tabbedCatalog.overrideTitle = _arg5;
                        };
                        m_tabbedCatalog.closeMarket = _arg6;
                    };
                };
                m_tabbedCatalog.addEventListener(MarketEvent.MARKET_BUY, onMarketClick, false, 0, true);
                m_tabbedCatalog.addEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu, false, 0, true);
                m_tabbedCatalog.addEventListener(CloseEvent.CLOSE, onCatalogClose, false, 0, true);
                Global.ui.bottomUI.addChild(m_tabbedCatalog);
                m_tabbedCatalog.show();
                if (m_catalog){
                    m_catalog.close();
                };
                UI.showNeighbors(false);
                m_tabbedCatalog.mouseEnabled = (m_tabbedCatalog.mouseChildren = true);
            };
            return (m_tabbedCatalog);
        }
        public static function displayCatalog(_arg1:String, _arg2:String=null, _arg3:Boolean=false, _arg4:String="", _arg5:Boolean=false, _arg6:Boolean=false, _arg7:Boolean=false):Catalog{
            var _local8:ItemCatalogUI;
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.MARKET_ASSETS)){
                return (null);
            };
            if (_arg1 == "close"){
                if (((m_catalog) && (m_catalog.parent))){
                    m_catalog.close();
                };
            };
            if (((m_catalog) && (m_catalog.parent))){
                if (_arg7){
                    m_catalog.exclusiveCategory = _arg3;
                    m_catalog.type = _arg1;
                };
                return (m_catalog);
            };
            if (_arg1 != "close"){
                Global.marketSessionTracker.startSession();
                if (m_catalog == null){
                    if (_arg1 == null){
                        _arg1 = "residence";
                    };
                    _local8 = new ItemCatalogUI();
                    m_catalog = new Catalog(_arg1, _local8, _arg2, _arg3, _arg4, _arg5);
                } else {
                    if (m_catalog != null){
                        if (_arg6){
                            m_catalog.showArrow();
                        };
                        if (((((((m_catalog.exclusiveCategory) && (!((_arg1 == "plot_contract"))))) && (!((_arg1 == "ship_contract"))))) && (!((_arg1 == "factory_contract"))))){
                            if (_arg1 == null){
                                _arg1 = "residence";
                                m_catalog.type = _arg1;
                            };
                        };
                        m_catalog.exclusiveCategory = _arg3;
                        if (_arg1 != null){
                            m_catalog.type = _arg1;
                        };
                        if (_arg2 != null){
                            m_catalog.item = _arg2;
                        };
                        if (((((((!((m_catalog.type == "plot_contract"))) && (!((m_catalog.type == "ship_contract"))))) && (!((m_catalog.type == "factory_contract"))))) && (!((m_catalog.type == "train"))))){
                            m_catalog.exclusiveCategory = false;
                        };
                        if (_arg4 != ""){
                            m_catalog.overrideTitle = _arg4;
                        };
                        m_catalog.closeMarket = _arg5;
                    };
                };
                m_catalog.addEventListener(MarketEvent.MARKET_BUY, onMarketClick, false, 0, true);
                m_catalog.addEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu, false, 0, true);
                m_catalog.addEventListener(CloseEvent.CLOSE, onCatalogClose, false, 0, true);
                Global.ui.bottomUI.addChild(m_catalog);
                m_catalog.show();
                if (m_tabbedCatalog){
                    m_tabbedCatalog.close();
                };
                UI.showNeighbors(false);
                m_catalog.mouseEnabled = (m_catalog.mouseChildren = true);
            };
            return (m_catalog);
        }
        public static function refreshCatalog(_arg1:Boolean):void{
            if (((!(UI.AUTO_CLOSE_MARKET)) || (_arg1))){
                m_catalog.type = m_catalog.type;
            };
        }
        public static function showNeighbors(_arg1:Boolean=true):void{
            if (_arg1){
                TweenLite.to(Global.ui.m_friendSprite, 0.5, {y:472});
            } else {
                TweenLite.to(Global.ui.m_friendSprite, 0.5, {y:722});
            };
        }
        public static function displayNewFranchise(_arg1:Boolean=false):FranchiseMenu{
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.FRANCHISE_ASSETS)){
                return (null);
            };
            if (_arg1){
                if (m_franchiseMenu){
                    if (Utilities.isFullScreen()){
                        m_franchiseMenu.y = ((Global.stage.stageHeight - m_franchiseMenu.height) / 2);
                    } else {
                        m_franchiseMenu.y = Global.hud.getComponent("coins").height;
                        m_franchiseMenu.x = ((Global.stage.stageWidth - m_franchiseMenu.width) / 2);
                    };
                };
                return (m_franchiseMenu);
            };
            if (m_franchiseMenu == null){
                m_franchiseMenu = new FranchiseMenu();
                Global.ui.addChild(m_franchiseMenu);
                m_franchiseMenu.alpha = 0;
                if (Utilities.isFullScreen()){
                    m_franchiseMenu.y = ((Global.stage.stageHeight - m_franchiseMenu.height) / 2);
                } else {
                    m_franchiseMenu.y = Global.hud.getComponent("coins").height;
                    m_franchiseMenu.x = ((Global.stage.stageWidth - m_franchiseMenu.width) / 2);
                };
                m_franchiseMenu.addEventListener(CloseEvent.CLOSE, onFranchiseClose_n, false, 0, true);
                TweenLite.to(m_franchiseMenu, 0.5, {alpha:1});
            };
            return (m_franchiseMenu);
        }
        public static function redirectToInvitePage(_arg1:String, _arg2:String=null, _arg3:Function=null):void{
            var _local4:String = ("invite.php?ref=" + _arg1);
            if (_arg2){
                _local4 = (_local4 + ("&view=" + _arg2));
            };
            FrameManager.showTray(_local4, null, _arg3);
        }
        private static function onFranchiseClose_n(_arg1:Event):void{
            var _local2:Array;
            var _local3:int;
            if (m_franchiseMenu){
                _local2 = Global.world.getActiveGameModes();
                _local3 = 0;
                while (_local3 < _local2.length) {
                    Global.world.removeGameMode(_local2[_local3]);
                    _local3++;
                };
                TweenLite.to(m_franchiseMenu, 0.5, {
                    alpha:0,
                    onComplete:endFranchise_n
                });
                Global.world.addGameMode(new GMPlay());
                m_franchiseMenu.removeEventListener(CloseEvent.CLOSE, onFranchiseClose_n);
            };
        }
        private static function endFranchise_n():void{
            m_franchiseMenu.visible = false;
            m_franchiseMenu = null;
        }
        private static function onFranchiseClick(_arg1:Event):void{
            Global.world.addGameMode(new GMPlaceMapResource("bus_bakery", Business, false));
        }
        private static function onFranchiseManagerClick(_arg1:Event):void{
            if (_arg1.type == FranchiseEvent.FRANCHISE_COLLECT){
            } else {
                if (_arg1.type == FranchiseEvent.FRANCHISE_REMIND){
                } else {
                    if (_arg1.type == FranchiseEvent.FRANCHISE_SUPPLY){
                    };
                };
            };
        }
        public static function displayCollectionFlyout(_arg1:String, _arg2:Point=null, _arg3:Point=null):Boolean{
            return (CollectionPanelPopout.getInstance().addItemByName(_arg1, _arg2, _arg3));
        }
        public static function displayCollectableFadeIn(_arg1:String):void{
            CollectionPanelPopout.getInstance().itemAppear(_arg1);
        }
        public static function checkCollectableFadeIn(_arg1:String):void{
            CollectionPanelPopout.getInstance().verifyCollection(_arg1);
        }
        public static function displayInventory(_arg1:String=null):Catalog{
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.INVENTORY_ASSETS)){
                return (null);
            };
            if (m_inventory == null){
                m_inventory = new InventoryView(_arg1);
            } else {
                if (((!((m_inventory.asset.shelf.currentItemName == _arg1))) && (!((_arg1 == null))))){
                    m_inventory.asset.goToItem(_arg1);
                };
            };
            if (!m_inventory.isShown){
                Global.ui.m_buyModeButton.setEnabled(false);
                m_inventory.addEventListener(MarketEvent.MARKET_BUY, onMarketClick, false, 0, true);
                m_inventory.addEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu, false, 0, true);
                m_inventory.addEventListener(CloseEvent.CLOSE, onInventoryClose, false, 0, true);
                Global.ui.addChild(m_inventory);
                m_inventory.show();
            } else {
                m_inventory.close();
            };
            return (m_inventory);
        }
        private static function onInventoryClose(_arg1:Event):void{
            if (m_inventory){
                Global.ui.hideExpandedMainMenu();
                Global.ui.switchDefaultActionButton(UIEvent.CURSOR);
                Global.ui.m_buyModeButton.setEnabled(true);
                m_inventory.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_inventory.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                m_inventory.removeEventListener(CloseEvent.CLOSE, onInventoryClose);
            };
        }
        public static function deinitializeInventory():void{
            if (m_inventory){
                if (m_inventory.forceStayOpen){
                    return;
                };
                if (m_inventory.isShown){
                    m_inventory.close();
                };
                m_inventory = null;
            };
        }
        public static function refreshInventory():void{
            if (((((m_inventory) && (m_inventory.isShown))) && (m_inventory.doRefreshInventory))){
                m_inventory.refreshInventory();
            };
        }
        public static function displayCollections(_arg1:String=null):Catalog{
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.INVENTORY_ASSETS)){
                return (null);
            };
            if (m_collections == null){
                m_collections = new CollectionView(_arg1);
            } else {
                if (m_collections.asset.shelf.currentItemName != _arg1){
                    m_collections.asset.goToItem(_arg1);
                };
            };
            if (!m_collections.isShown){
                m_collections.addEventListener(MarketEvent.MARKET_BUY, onMarketClick, false, 0, true);
                m_collections.addEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu, false, 0, true);
                m_collections.addEventListener(CloseEvent.CLOSE, onCollectionsClose, false, 0, true);
                Global.ui.addChild(m_collections);
                m_collections.show();
            };
            Global.ui.m_buyModeButton.setEnabled(false);
            return (m_collections);
        }
        private static function onCollectionsClose(_arg1:Event):void{
            var _local2:Array;
            var _local3:int;
            if (m_collections){
                _local2 = Global.world.getActiveGameModes();
                _local3 = 0;
                while (_local3 < _local2.length) {
                    Global.world.removeGameMode(_local2[_local3]);
                    _local3++;
                };
                Global.world.addGameMode(new GMPlay());
                Global.ui.hideExpandedMainMenu();
                Global.ui.switchDefaultActionButton(UIEvent.CURSOR);
                Global.ui.m_buyModeButton.setEnabled(true);
                m_collections.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_collections.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                m_collections.removeEventListener(CloseEvent.CLOSE, onInventoryClose);
            };
        }
        public static function displayVisitorCenterDialog():VisitorCenterDialog{
            if (Global.world.vistorCenterText){
                m_visitorDlg = new VisitorCenterDialog(Global.world.vistorCenterText, "VisitorUI", 0, null, "VisitorUI");
            } else {
                m_visitorDlg = new VisitorCenterDialog(ZLoc.t("Dialogs", "VisitorUI_message"), "VisitorUI", 0, null, "VisitorUI");
            };
            if (Global.ui.m_toolTip){
                Global.stage.removeChild(Global.ui.m_toolTip);
            };
            Global.ui.addChild(m_visitorDlg);
            m_visitorDlg.show();
            m_visitorDlg.addEventListener(Event.CLOSE, removeVisDialog, false, 0, true);
            return (m_visitorDlg);
        }
        private static function removeVisDialog(_arg1:Event):void{
            Global.stage.addChild(Global.ui.m_toolTip);
            Global.ui.removeChild(m_visitorDlg);
            m_visitorDlg.removeEventListener(Event.CLOSE, removeVisDialog);
            m_visitorDlg = null;
        }
        public static function displayValentineDialog():ValentineDialog{
            if (m_vDlg == null){
                m_vDlg = new ValentineDialog();
                Global.ui.addChild(m_vDlg);
                m_vDlg.show();
                m_vDlg.addEventListener(Event.CLOSE, removeValDialog, false, 0, true);
            };
            return (m_vDlg);
        }
        private static function removeValDialog(_arg1:Event):void{
            Global.ui.removeChild(m_vDlg);
            m_vDlg.removeEventListener(Event.CLOSE, removeValDialog);
            m_vDlg = null;
        }
        public static function displayMunicipalUpgradesDialog(_arg1:String, _arg2:Array, _arg3:Function, _arg4:Function, _arg5:Function, _arg6:Number):MunicipalUpgradesDialog{
            if (m_municipalUpgradesDialog == null){
                m_municipalUpgradesDialog = new MunicipalUpgradesDialog(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
                Global.ui.addChild(m_municipalUpgradesDialog);
                Global.ui.displayLightbox(true, MASK_GAME_AND_BOTTOMBAR, true);
                m_municipalUpgradesDialog.show();
                if (((Global.ui.m_toolTip) && (Global.stage.contains(Global.ui.m_toolTip)))){
                    Global.stage.removeChild(Global.ui.m_toolTip);
                };
                m_municipalUpgradesDialog.addEventListener(Event.CLOSE, removeMunicipalUpgradesDialog, false, 0, true);
            };
            return (m_municipalUpgradesDialog);
        }
        private static function removeMunicipalUpgradesDialog(_arg1:Event):void{
            if (Global.ui.m_toolTip){
                Global.stage.addChild(Global.ui.m_toolTip);
            };
            Global.ui.removeChild(m_municipalUpgradesDialog);
            Global.ui.displayLightbox(false);
            m_municipalUpgradesDialog.removeEventListener(Event.CLOSE, removeMunicipalUpgradesDialog);
            m_municipalUpgradesDialog = null;
        }
        private static function removeMunInventoryUpgradesDialog(_arg1:Event):void{
            if (Global.ui.m_toolTip){
                Global.stage.addChild(Global.ui.m_toolTip);
            };
            Global.ui.removeChild(m_munInventoryUpgradesDialog);
            Global.ui.displayLightbox(false);
            m_munInventoryUpgradesDialog.removeEventListener(Event.CLOSE, removeMunInventoryUpgradesDialog);
            m_munInventoryUpgradesDialog = null;
        }
        public static function displayMunInventoryUpgradesDialog(_arg1:String, _arg2:Array, _arg3:Function, _arg4:Function, _arg5:Function, _arg6:Number):MunInventoryUpgradesDialog{
            if (m_munInventoryUpgradesDialog == null){
                m_munInventoryUpgradesDialog = new MunInventoryUpgradesDialog(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6);
                Global.ui.addChild(m_munInventoryUpgradesDialog);
                Global.ui.displayLightbox(true, MASK_GAME_AND_BOTTOMBAR, true);
                m_munInventoryUpgradesDialog.show();
                if (((Global.ui.m_toolTip) && (Global.stage.contains(Global.ui.m_toolTip)))){
                    Global.stage.removeChild(Global.ui.m_toolTip);
                };
                m_munInventoryUpgradesDialog.addEventListener(Event.CLOSE, removeMunInventoryUpgradesDialog, false, 0, true);
            };
            return (m_munInventoryUpgradesDialog);
        }
        public static function displayBusinessUpgradesDialog(_arg1:MapResource, _arg2:Function, _arg3:Function, _arg4:Function):BusinessUpgradesDialog{
            if (m_businessUpgradesDialog == null){
                m_businessUpgradesDialog = new BusinessUpgradesDialog(_arg1, _arg2, _arg3, _arg4);
                Global.ui.addChild(m_businessUpgradesDialog);
                Global.ui.displayLightbox(true, MASK_GAME_AND_BOTTOMBAR, true);
                m_businessUpgradesDialog.show();
                if (((Global.ui.m_toolTip) && (Global.stage.contains(Global.ui.m_toolTip)))){
                    Global.stage.removeChild(Global.ui.m_toolTip);
                };
                m_businessUpgradesDialog.addEventListener(Event.CLOSE, removeBusinessUpgradesDialog, false, 0, true);
            };
            return (m_businessUpgradesDialog);
        }
        private static function removeBusinessUpgradesDialog(_arg1:Event):void{
            if (Global.ui.m_toolTip){
                Global.stage.addChild(Global.ui.m_toolTip);
            };
            Global.ui.removeChild(m_businessUpgradesDialog);
            Global.ui.displayLightbox(false);
            m_businessUpgradesDialog.removeEventListener(Event.CLOSE, removeBusinessUpgradesDialog);
            m_businessUpgradesDialog = null;
        }
        public static function displayCopsDialog():CopsDialog{
            m_copsDlg = new CopsDialog();
            Global.ui.addChild(m_copsDlg);
            Global.ui.displayLightbox(true, MASK_GAME_AND_BOTTOMBAR, true);
            m_copsDlg.show();
            m_copsDlg.addEventListener(Event.CLOSE, removeCopsDialog, false, 0, true);
            if (((Global.ui.m_toolTip) && (Global.stage.contains(Global.ui.m_toolTip)))){
                Global.stage.removeChild(Global.ui.m_toolTip);
            };
            return (m_copsDlg);
        }
        public static function displayPeddlerMarketDialog():CopsDialog{
            m_peddlerMarketDlg = new PeddlerMarketDialog();
            Global.ui.addChild(m_peddlerMarketDlg);
            Global.ui.displayLightbox(true, MASK_GAME_AND_BOTTOMBAR, true);
            m_peddlerMarketDlg.show();
            m_peddlerMarketDlg.addEventListener(Event.CLOSE, removePeddlerMarketDialog, false, 0, true);
            if (((Global.ui.m_toolTip) && (Global.stage.contains(Global.ui.m_toolTip)))){
                Global.stage.removeChild(Global.ui.m_toolTip);
            };
            return (m_peddlerMarketDlg);
        }
        public static function refreshPeddlerMarketDialogData():void{
            if (m_peddlerMarketDlg){
                (m_peddlerMarketDlg.view as PeddlerMarketDialogView).refreshData();
            };
        }
        public static function requestPatrol(_arg1:MapResource, _arg2:String=null, _arg3:int=-1):void{
            if (m_copsDlg){
                m_waitingPatrols.push({
                    target:_arg1,
                    type:_arg2,
                    slot:_arg3
                });
            } else {
                BanditManager.addPatrol(_arg1, _arg2, _arg3);
            };
        }
        public static function get waitingPatrols():Array{
            return (m_waitingPatrols);
        }
        private static function removeCopsDialog(_arg1:Event):void{
            var _local2:Object;
            if (m_copsDlg){
                Global.stage.addChild(Global.ui.m_toolTip);
                Global.ui.removeChild(m_copsDlg);
                Global.ui.displayLightbox(false);
                m_copsDlg.removeEventListener(Event.CLOSE, removeValDialog);
                m_copsDlg = null;
                if (m_waitingPatrols.length){
                    for each (_local2 in m_waitingPatrols) {
                        BanditManager.addPatrol(_local2.target, _local2.type, _local2.slot);
                    };
                };
                m_waitingPatrols = [];
            };
        }
        private static function removePeddlerMarketDialog(_arg1:Event):void{
            var _local2:Object;
            if (m_peddlerMarketDlg){
                Global.stage.addChild(Global.ui.m_toolTip);
                Global.ui.removeChild(m_peddlerMarketDlg);
                Global.ui.displayLightbox(false);
                m_peddlerMarketDlg.removeEventListener(Event.CLOSE, removeValDialog);
                m_peddlerMarketDlg = null;
                if (m_waitingPatrols.length){
                    for each (_local2 in m_waitingPatrols) {
                        BanditManager.addPatrol(_local2.target, _local2.type, _local2.slot);
                    };
                };
                m_waitingPatrols = [];
            };
        }
        public static function displayValentineCardViewer(_arg1:Admirer):ValentineCardViewDialog{
            var _local3:ValentineCard;
            var _local4:ValentineCardViewDialog;
            var _local2:Array = ValentineManager.getValentinesFromUID(_arg1.uid);
            for each (_local3 in _local2) {
                if (_local3.id.charAt(0) != "i"){
                    break;
                };
                _local3.id = _local3.id.slice(1);
            };
            _local2.sortOn("id", Array.NUMERIC);
            _local4 = new ValentineCardViewDialog(_local2, _arg1);
            UI.displayPopup(_local4);
            return (_local4);
        }
        public static function displayMarketDialog(_arg1:String="unknown", _arg2:String="tool", _arg3:String="all"):Market{
            if (m_marketWindow == null){
                m_marketWindow = new Market(_arg1, _arg2, _arg3);
                m_marketWindow.addEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_marketWindow.addEventListener(CloseEvent.CLOSE, onMarketClose);
                displayPopup(m_marketWindow);
                GlobalEngine.socialNetwork.publishFeedStory("VisitMarket", {}, [], true);
            };
            return (m_marketWindow);
        }
        public static function displayMiniMarketDialog(_arg1:Array, _arg2:String="unknown", _arg3:String="tool", _arg4:Function=null):Market{
            if (m_marketWindow == null){
                m_marketWindow = new MiniMarket(_arg1, _arg2, _arg3);
                m_marketWindow.setCloseClickCallback(_arg4);
                m_marketWindow.addEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_marketWindow.addEventListener(CloseEvent.CLOSE, onMarketClose);
                displayPopup(m_marketWindow);
            };
            return (m_marketWindow);
        }
        public static function refreshMarketDialog():void{
            if (m_marketWindow != null){
                m_marketWindow.refreshLayout();
            };
        }
        public static function getMarketDialog():Market{
            return (m_marketWindow);
        }
        public static function isViewOpen(_arg1):Boolean{
            var _local3:DisplayObject;
            var _local4:Boolean;
            var _local2:int = Global.ui.numChildren;
            while (_local2--) {
                _local3 = Global.ui.getChildAt(_local2);
                _local4 = Boolean((_local3 is _arg1));
                if (_local4){
                    return (true);
                };
            };
            return (false);
        }
        public static function displayItemStorageDialog(_arg1:ItemStorage):Catalog{
            if (resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.INVENTORY_ASSETS)){
                return (null);
            };
            if ((((m_storage == null)) || (!((m_storage.storageItem == _arg1))))){
                m_storage = new StorageView(_arg1);
            } else {
                m_storage.refresh();
            };
            if (!m_storage.isShown){
                Global.ui.m_buyModeButton.setEnabled(false);
                m_storage.addEventListener(MarketEvent.MARKET_BUY, onMarketClick, false, 0, true);
                m_storage.addEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu, false, 0, true);
                m_storage.addEventListener(CloseEvent.CLOSE, onItemStorageClose, false, 0, true);
                Global.ui.addChild(m_storage);
                m_storage.show();
            } else {
                m_storage.close();
            };
            return (m_storage);
        }
        private static function onItemStorageClose(_arg1:Event=null):void{
            if (m_storage){
                Global.ui.hideExpandedMainMenu();
                Global.ui.switchDefaultActionButton(UIEvent.CURSOR);
                Global.ui.m_buyModeButton.setEnabled(true);
                m_storage.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_storage.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                m_storage.removeEventListener(CloseEvent.CLOSE, onStorageClose);
            };
        }
        public static function displayGiftDialog():void{
            if (m_giftSellWindow == null){
                if (Global.player.getGiftCount() > 0){
                    m_giftSellWindow = new GiftSellDialog();
                    m_giftSellWindow.addEventListener(MarketEvent.MARKET_GIFT, onMarketClick);
                    m_giftSellWindow.addEventListener(CloseEvent.CLOSE, onSellGiftClose);
                    UI.displayPopup(m_giftSellWindow);
                } else {
                    m_giftSellWindow = new GiftSellDialog();
                    StatsManager.count("farmville_sell_gift_screen", "click_sell_all_item", "gifts_empty_impression");
                    UI.displayMessage(ZLoc.t("Dialogs", "NoMoreGiftsToSell"), GenericPopup.TYPE_YESNO, noMoreGiftsHandler, "noMoreGiftsHandler", true);
                };
            };
        }
        public static function displayStorageDialog(_arg1:SlotDialog):void{
            if (m_storageWindow != null){
                m_storageWindow.removeEventListener(MarketEvent.MARKET_GIFT, onMarketClick);
                m_storageWindow.removeEventListener(CloseEvent.CLOSE, onStorageClose);
                m_storageWindow.close();
                m_storageWindow = null;
            };
            m_storageWindow = _arg1;
            m_storageWindow.addEventListener(MarketEvent.MARKET_GIFT, onMarketClick);
            m_storageWindow.addEventListener(CloseEvent.CLOSE, onStorageClose);
            UI.displayPopup(m_storageWindow);
        }
        public static function displayOutOfGoodsDialog():void{
            var customDlg:* = null;
            customDlg = new CustomDialog(ZLoc.t("Dialogs", "TrainUI_OutOfGoods_message"), "OutOfGoods", "TrainUI_OutOfGoods", "assets/dialogs/outOfGoods.png", GenericDialogView.ICON_POS_BOTTOM);
            customDlg.addButton(ZLoc.t("Dialogs", "TrainUI_BuyCrop"), Curry.curry(function (_arg1:GenericDialog, _arg2:Event):void{
                UI.displayCatalog("farming", null, false, "", true, false, true);
                if (customDlg){
                    customDlg.close();
                };
            }, customDlg));
            var trainStation:* = Global.world.citySim.trainManager.trainStation;
            var trainQuest:* = Global.questManager.getQuestByName(trainStation.getItem().requiredQuestFlag);
            if (((((!((trainQuest == null))) && (trainQuest.hasCompleted))) || ((((trainQuest == null)) && (Global.player.isQuestCompleted(trainStation.getItem().requiredQuestFlag)))))){
                customDlg.addButton(ZLoc.t("Dialogs", "TrainUI_SendTrain"), Curry.curry(function (_arg1:GenericDialog, _arg2:Event):void{
                    Global.world.citySim.trainManager.showTrainScheduleCatalog();
                    if (customDlg){
                        customDlg.close();
                    };
                }, customDlg));
            };
            customDlg.buildCustomDialog();
            UI.displayPopup(customDlg);
        }
        private static function onCatalogClose(_arg1:CloseEvent):void{
            var _local2:Array;
            var _local3:GameMode;
            if (Global.isVisiting()){
                if (((!(AUTO_CLOSE_MARKET)) || (((((AUTO_CLOSE_MARKET) && (!((Global.world.getTopGameMode() is GMPlaceBizOnLotSite))))) && (Global.isVisiting()))))){
                    Global.franchiseManager.placementMode = false;
                };
            };
            if (m_catalog){
                if ((((_arg1.bKeepState == false)) && (!(UI.AUTO_CLOSE_MARKET)))){
                    _local2 = Global.world.getActiveGameModes();
                    if (Global.isVisiting()){
                        _local3 = new GMVisit(Global.world.ownerId);
                    } else {
                        _local3 = new GMPlay();
                    };
                    Global.world.addGameMode(_local3, true);
                };
                Global.ui.hideExpandedMainMenu();
                m_catalog.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_catalog.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                m_catalog.removeEventListener(CloseEvent.CLOSE, onCatalogClose);
                m_catalog.mouseChildren = (m_catalog.mouseEnabled = false);
            };
        }
        private static function onMarketMenu(_arg1:Event):void{
            var _local2:Catalog;
            if (Global.ui.m_bExpandedMenuOpen == true){
                Global.ui.hideExpandedMainMenu();
                Global.ui.m_bExpandedMenuOpen = false;
            } else {
                _local2 = null;
                if (((_arg1.currentTarget) && ((_arg1.currentTarget is Catalog)))){
                    _local2 = (_arg1.currentTarget as Catalog);
                };
                Global.ui.m_bExpandedMenuOpen = Global.ui.displayExpandedMainMenu(ExpandedMainMenu, _local2);
            };
        }
        private static function onMarketClose(_arg1:Event):void{
            if (m_marketWindow){
                m_marketWindow.removeEventListener(CloseEvent.CLOSE, onMarketClose);
                m_marketWindow = null;
            };
        }
        private static function onStorageClose(_arg1:Event):void{
            if (m_storageWindow){
                m_storageWindow.removeEventListener(CloseEvent.CLOSE, onSellGiftClose);
                m_storageWindow = null;
            };
        }
        private static function onSellGiftClose(_arg1:Event):void{
            if (m_giftSellWindow){
                m_giftSellWindow.removeEventListener(CloseEvent.CLOSE, onSellGiftClose);
                m_giftSellWindow = null;
            };
        }
        private static function onNoGiftClose(_arg1:GenericPopupEvent):void{
            m_giftSellWindow = null;
        }
        private static function noMoreGiftsHandler(_arg1:GenericPopupEvent):void{
            var _local2 = (_arg1.button == GenericPopup.YES);
            if (_local2 == true){
                StatsManager.count("farmville_sell_gift_screen", "click_sell_all_item", "gifts_empty_accept");
                GlobalEngine.socialNetwork.redirect("gifts.php?ref=empty_gift_box");
            } else {
                StatsManager.count("farmville_sell_gift_screen", "click_sell_all_item", "gifts_empty_cancel");
            };
            m_giftSellWindow = null;
        }
        public static function onMarketClick(_arg1:MarketEvent):void{
            var _local6:Item;
            var _local7:Object;
            var _local8:StorageType;
            var _local9:String;
            var _local10:int;
            var _local11:int;
            var _local12:int;
            var _local13:String;
            var _local14:int;
            var _local15:String;
            var _local16:String;
            var _local2:Boolean;
            var _local3:int;
            var _local4:int;
            var _local5:GameMode;
            m_lastMarketEventItemName = _arg1.item;
            if (m_marketWindow){
                m_marketWindow.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                m_marketWindow = null;
            } else {
                if (m_giftSellWindow){
                    _local2 = true;
                    m_giftSellWindow.removeEventListener(MarketEvent.MARKET_GIFT, onMarketClick);
                    _local3 = Global.world.GIFTBOX_ID;
                    m_giftSellWindow = null;
                } else {
                    if (_arg1.eventSource == MarketEvent.SOURCE_INVENTORY){
                        if (((m_inventory) && ((_arg1.target == m_inventory)))){
                            Global.ui.m_buyModeButton.setEnabled(true);
                            if (!m_inventory.forceStayOpen){
                                m_inventory.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                                m_inventory.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                                m_inventory.removeEventListener(CloseEvent.CLOSE, onInventoryClose);
                                m_inventory = null;
                            };
                        } else {
                            _arg1.target.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                        };
                        _local2 = true;
                        if (Global.player.inventory.getItemCountByName(_arg1.item) <= 0){
                            return;
                        };
                    } else {
                        if (((m_storage) && ((_arg1.eventSource == MarketEvent.SOURCE_STORAGE)))){
                            Global.ui.m_buyModeButton.setEnabled(true);
                            m_storage.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                            m_storage.removeEventListener(UIEvent.OPEN_ACTION_MENU, onMarketMenu);
                            m_storage.removeEventListener(CloseEvent.CLOSE, onInventoryClose);
                            _local8 = m_storage.storageType;
                            _local9 = m_storage.storageKey;
                            m_storage = null;
                            _local2 = true;
                            _local10 = Global.player.storageComponent.getStorageUnit(_local8, _local9).getItemCountByName(_arg1.item);
                            if (_local10 <= 0){
                                onItemStorageClose();
                            };
                            _local5 = new GMPlaceFromStorage(_local8, _local9, _arg1.item, Decoration);
                        } else {
                            if (m_catalog){
                                if (AUTO_CLOSE_MARKET){
                                    m_catalog.removeEventListener(MarketEvent.MARKET_BUY, onMarketClick);
                                };
                            };
                        };
                    };
                };
            };
            _local6 = Global.gameSettings.getItemByName(_arg1.item);
            switch (_arg1.eventType){
                case MarketEvent.RESIDENCE:
                    if (!_local5){
                        _local5 = new GMPlaceMapResource(_arg1.item, Residence, _local2);
                    };
                    _local11 = _local6.populationBase;
                    if ((Global.world.citySim.getTotalPopulation() + _local11) > Global.world.citySim.getPopulationCap()){
                        _local7 = {capNeeded:Global.world.citySim.getRequiredPopulationCap(_local6)};
                        ResourceExplanationDialog.show(ResourceExplanationDialog.TYPE_NOT_ENOUGH_HAPPINESS_RESIDENCE, false, null, _local7);
                    } else {
                        Global.world.addGameMode(_local5);
                    };
                    break;
                case MarketEvent.BUSINESS:
                    if (((!(Global.franchiseManager.placementMode)) && ((_arg1.item == "biz_lotsite_4x4")))){
                        if (!_local5){
                            _local5 = new GMPlaceMapResource(_arg1.item, null, _local2);
                        };
                        Global.world.addGameMode(_local5);
                    } else {
                        if (!Global.franchiseManager.placementMode){
                            _local14 = Math.floor((Global.world.citySim.getPopulationCap() * Global.gameSettings.getNumber("businessLimitByPopulationMax")));
                            if ((Global.world.citySim.getTotalBusinesses() + 1) > _local14){
                                _local7 = {capNeeded:Global.world.citySim.getRequiredPopulationCap(_local6)};
                                ResourceExplanationDialog.show(ResourceExplanationDialog.TYPE_NOT_ENOUGH_HAPPINESS_BUSINESS, false, null, _local7);
                            } else {
                                if (!_local5){
                                    _local5 = new GMPlaceMapResource(_arg1.item, Business, _local2);
                                };
                                Global.world.addGameMode(_local5);
                            };
                        } else {
                            if (((Global.franchiseManager.placementMode) && ((_arg1.item == "biz_lotsite_4x4")))){
                                UI.displayMessage(ZLoc.t("Dialogs", "BusinessZoneRestrict"));
                            } else {
                                if (Global.world.getTopGameMode().getLotSite() != null){
                                    if (!_local5){
                                        _local5 = new GMPlaceBizOnLotSite(Global.world.getTopGameMode().getLotSite(), _arg1.item, Business, _local2);
                                    };
                                    Global.world.addGameMode(_local5);
                                } else {
                                    _local15 = Global.player.getFriendFirstName(Global.getVisiting());
                                    _local16 = Global.franchiseManager.getFranchiseName(_arg1.item, Global.player.uid);
                                    UI.displayMessage(ZLoc.t("Dialogs", "RequestFranchiseConfirm", {
                                        friendName:_local15,
                                        franchiseName:_local16
                                    }), GenericPopup.TYPE_YESNO, confirmFranchiseHandler, "confirmFranchiseHandler", true, null, "", 0, true);
                                };
                            };
                        };
                    };
                    break;
                case MarketEvent.EXPAND_FARM:
                    if (!_local5){
                        _local5 = new GMExpand(_arg1.item);
                    };
                    if (!Global.isVisiting()){
                        Global.world.addGameMode(_local5);
                    };
                    break;
                case MarketEvent.CONTRACT:
                    if (!_local5){
                        _local5 = new GMPlant(_arg1.item);
                    };
                    if (((!(Global.isVisiting())) && (_local6.multiplant))){
                        Global.world.addGameMode(_local5);
                    };
                    break;
                case MarketEvent.EXTRA:
                    if (!Global.isVisiting()){
                        GameTransactionManager.addTransaction(new TBuyEnergy(_arg1.item, _local2));
                    };
                    break;
                case MarketEvent.THEME_COLLECTION:
                    GameTransactionManager.addTransaction(new TSetCurrentThemes(_arg1.item, !(Global.world.isThemeCollectionEnabled(_local6))), true, true);
                    break;
                case MarketEvent.GOODS:
                    if (!Global.isVisiting()){
                        GameTransactionManager.addTransaction(new TBuyGoods(_arg1.item, _local2));
                    };
                    break;
                case MarketEvent.GENERIC:
                    if (!_local5){
                        _local5 = new GMPlaceMapResource(_arg1.item, null, _local2);
                    };
                    Global.world.addGameMode(_local5);
                    break;
                case MarketEvent.TRAIN:
                    Global.world.citySim.trainManager.proposeSchedulePurchase(_arg1.item);
                    break;
                case MarketEvent.FBC_PURCHASE:
                    _local12 = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_STARTER_PACK);
                    _local13 = getMarketTab(_arg1.eventSource);
                    StatsManager.sample(100, StatsCounterType.GAME_ACTIONS, StatsKingdomType.ACTION_MENU, ("starter_pack_click" + _local12), _local13);
                    new StartUpDialogHelper().purchaseStarterPack(_local12);
                    break;
                case MarketEvent.BRIDGE:
                    if (!_local5){
                        _local5 = new GMPlaceBridge(_arg1.item, Bridge, _local2);
                    };
                    Global.world.addGameMode(_local5);
                    break;
            };
        }
        private static function confirmFranchiseHandler(_arg1:GenericPopupEvent):void{
            var _local3:Number;
            var _local4:LotSite;
            var _local5:Business;
            var _local2 = (_arg1.button == GenericPopup.YES);
            if (_local2 == true){
                _local3 = -1;
                _local4 = Global.world.citySim.lotManager.getDefaultLotSite();
                if (_local4){
                    _local3 = _local4.getId();
                };
                Global.world.citySim.lotManager.placeOrder(Global.getVisiting(), _local3, m_lastMarketEventItemName);
                _local5 = Global.franchiseManager.getBusinessFromType(m_lastMarketEventItemName);
                FranchiseViralManager.triggerFranchiseViralFeeds(FranchiseViralManager.VIRAL_APPROVEBUILDINGREQUEST, m_lastMarketEventItemName);
                Global.player.conditionallyUpdateHUD();
            };
        }
        private static function getMarketTab(_arg1:String):String{
            switch (_arg1){
                case "extras":
                    return ("energy");
                case "decorRoads":
                    return ("decorations");
                case "new":
                    return ("new");
                default:
                    return ("");
            };
        }
        public static function displayPermitBuyPopup(_arg1:int, _arg2:int, _arg3:Function, _arg4:Function):void{
            var _local5:GenericDialog;
            var _local6 = "PermitDialog_message";
            if (ExpansionManager.instance.getBehaviorExperimentVariant() == ExperimentDefinitions.NEW_EXPANSION_BEHAVIOR_ACTIVATED){
                _local6 = "PermitDialog_message_more";
            };
            _local5 = new PermitBuyShareDialog(_arg1, _arg2, _arg3, _arg4, _local6);
            UI.displayPopup(_local5, false, "", true);
        }
        public static function displayNeighborBuyPopup(_arg1:int, _arg2:int, _arg3:Function, _arg4:Function):void{
            var _local5:GenericDialog;
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            _local5 = new PermitBuyShareDialog(_arg1, _arg2, _arg3, _arg4, "NeighborBuyDialog_message", "NeighborBuyDialog", null, GenericDialogView.TYPE_INVITEFRIENDS_BUYNEIGHBORS);
            UI.displayPopup(_local5, false, "", true);
        }
        public static function displayFranchiseUnlockBuyPopup(_arg1:int, _arg2:int, _arg3:Function, _arg4:Function):void{
            var _local5:GenericDialog;
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            _local5 = new PermitBuyShareDialog(_arg1, _arg2, _arg3, _arg4, "FranchiseUnlockBuyDialog_message", "FranchiseUnlockBuyDialog", "assets/businesses/bus_franchise/franchiselot.png", GenericDialogView.TYPE_INVITEFRIENDS_BUYNEIGHBORS);
            UI.displayPopup(_local5, false, "", true);
        }
        public static function displayImpulseBuyPopup(_arg1:String, _arg2:String=null):void{
            if (_arg2 == null){
                _arg2 = ImpulseBuy.POPUP_NAME;
            };
            var _local3:DisplayObject = Global.stage.getChildByName(_arg2);
            if (_local3 == null){
                if (LocaleHelper.localSetting.sns.cash_enable){
                    displayPopup(new ImpulseBuy(_arg1), false, _arg2, true);
                };
            };
        }
        protected static function onFeaturePromo(_arg1:int):void{
            StatsManager.count("featurePromo", ("feature_" + _arg1));
            if (Global.isVisiting() == false){
                switch (_arg1){
                    case 0:
                        UI.displayMarketDialog("featurePromo", "decoration");
                        break;
                    case 1:
                        UI.displayMarketDialog("featurePromo", "change_farm");
                        break;
                    case 2:
                        GlobalEngine.socialNetwork.redirect("gifts.php?ref=promo");
                        break;
                };
            };
        }
        public static function pushBlankCursor():void{
            if (m_cursors.length > 0){
                if (m_cursors[(m_cursors.length - 1)].displayObj != null){
                    setCursor(null);
                };
            };
        }
        public static function popBlankCursor():void{
            if (m_cursors.length > 0){
                if (m_cursors[(m_cursors.length - 1)].displayObj == null){
                    removeCursor(m_cursors[(m_cursors.length - 1)].id);
                };
            };
        }
        public static function get isModalDialogOpen():Boolean{
            return (m_isModalDialogOpen);
        }
        public static function displayInventoryMaxExceededDialog():void{
            var _local1:String = ZLoc.t("Dialogs", "InventoryCapError_message");
            var _local2 = "OkButton";
            var _local3 = "InventoryCapError";
            displayMessage(_local1, GenericPopup.TYPE_OK, null, _local3, true, null, _local3);
        }
        public static function get questManagerView():QuestManagerView{
            var _local1:int;
            if (!m_questManagerView){
                _local1 = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_QUEST_MANAGER);
                if (_local1 == ExperimentDefinitions.USE_QUEST_MANAGER){
                    m_questManagerView = new QuestManagerView();
                };
            };
            return (m_questManagerView);
        }
        public static function displayQuestManager():QuestManagerView{
            if (!m_questManagerView){
                m_questManagerView = new QuestManagerView();
            };
            if (!m_questManagerView.isShown){
                m_questManagerView.addEventListener(CloseEvent.CLOSE, onQuestManagerClose, false, 0, true);
                Global.ui.addChild(m_questManagerView);
                m_questManagerView.show();
            } else {
                m_questManagerView.close();
            };
            return (m_questManagerView);
        }
        private static function onQuestManagerClose(_arg1:Event):void{
            if (m_questManagerView){
                m_questManagerView.removeEventListener(CloseEvent.CLOSE, onQuestManagerClose);
            };
        }

        private function stageClickHandler(_arg1:MouseEvent):void{
            this.reconfigureSettingsMenu();
        }
        private function reconfigureSettingsMenu():void{
            if (this.m_settingsMenu.isEnabled){
                this.settingsToggleClickHandler(null);
            } else {
                if (!Global.guide.isActive()){
                    this.m_settingsMenu.setEndPostTutorialTransition();
                };
            };
        }
        public function showTickerMessage(_arg1:String, _arg2:Boolean=false):void{
            this.m_toasterManager.show(new TickerToaster(_arg1), !(_arg2));
        }
        protected function blockCityName(_arg1:MouseEvent):void{
            var _local3:GMDefault;
            var _local2:GameMode = Global.world.getTopGameMode();
            if ((_local2 is GMDefault)){
                _local3 = (_local2 as GMDefault);
                _local3.turnOffObject();
            };
            _arg1.stopImmediatePropagation();
            _arg1.stopPropagation();
        }
        private function createModeButtons():void{
            var _local1:Number = 0.75;
            var _local2 = 652;
            var _local3 = 15;
            var _local4:int = (68 * _local1);
            var _local5:int = (68 * _local1);
            this.m_defaultModeButton = new SpriteButton(EmbeddedArt.tool_offstate_btn, EmbeddedArt.tool_onstate_btn, EmbeddedArt.tool_onstate_btn, this.onDefaultModeClick);
            this.m_defaultModeButton.x = _local2;
            this.m_defaultModeButton.y = _local3;
            this.m_friendSprite.addChild(this.m_defaultModeButton);
            this.m_franchiseModeButton = new SpriteButton(EmbeddedArt.franchise_offstate_btn, EmbeddedArt.franchise_onstate_btn, EmbeddedArt.franchise_onstate_btn, this.onNewsModeClick);
            this.m_franchiseModeButton.x = ((_local2 + _local5) - 3);
            this.m_franchiseModeButton.y = _local3;
            this.m_friendSprite.addChild(this.m_franchiseModeButton);
            this.m_buyModeButton = new SpriteButton(EmbeddedArt.build_offstate_btn, EmbeddedArt.build_onstate_btn, EmbeddedArt.build_onstate_btn, this.onBuyModeClick, ZLoc.t("Main", "Build"));
            LocaleHelper.localSetting.TextField_adjust(this.m_buyModeButton.getTextField(), {height:24});
            this.m_buyModeButton.x = _local2;
            this.m_buyModeButton.y = (_local3 + _local4);
            this.m_friendSprite.addChild(this.m_buyModeButton);
        }
        private function switchDefaultActionButton(_arg1:String):void{
            if (this.m_defaultModeButton != null){
                this.m_friendSprite.removeChild(this.m_defaultModeButton);
            };
            this.m_defaultModeButton = null;
            this.m_actionMenuMode = _arg1;
            switch (_arg1){
                case UIEvent.CURSOR:
                    this.m_defaultModeButton = new SpriteButton(EmbeddedArt.tool_offstate_btn, EmbeddedArt.tool_onstate_btn, EmbeddedArt.tool_onstate_btn, this.onDefaultModeClick);
                    break;
                default:
                    this.m_defaultModeButton = new SpriteButton(EmbeddedArt.tool_cancel_up, EmbeddedArt.tool_cancel_over, EmbeddedArt.tool_cancel_over, this.onDefaultModeClick);
            };
            this.m_friendSprite.addChild(this.m_defaultModeButton);
            this.m_defaultModeButton.x = 652;
            this.m_defaultModeButton.y = 15;
            this.m_selectedActionMode = _arg1;
        }
        public function displayExpandedMainMenu(_arg1:Class, _arg2:Catalog=null):Boolean{
            if (!Global.world.isDefaultGameMode()){
                this.setActionMenuMode(UIEvent.CURSOR, true);
                return (false);
            };
            if (Global.isVisiting()){
                return (false);
            };
            if ((((this.m_expandedMenu == null)) || (!(this.m_bExpandedMenuOpen)))){
                this.m_expandedMenu = new _arg1(this.m_bottomUI, false);
            };
            var _local3:int;
            var _local4:Vector2 = this.m_expandedMenu.getDesiredPosition(_arg2);
            this.m_expandedMenu.setX(_local4.x);
            _local3 = _local4.y;
            this.m_expandedMenu.setY((_local3 + 100));
            this.m_expandedMenu.alpha = 0;
            this.m_expandedMenu.show();
            TweenLite.to(this.m_expandedMenu, 0.2, {
                y:_local3,
                alpha:1
            });
            this.m_expandedMenu.addEventListener(UIEvent.ACTION_MENU_CLICK, this.onActionMenuClick, false, 0, true);
            this.m_expandedMenu.addEventListener(MouseEvent.MOUSE_DOWN, this.onExpandedMainMenuClick, false, 0, true);
            Global.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.onActionMenuStageClick, false, 0, true);
            return (true);
        }
        private function onExpandedMainMenuClick(_arg1:MouseEvent):void{
            _arg1.stopImmediatePropagation();
            _arg1.stopPropagation();
        }
        public function hideExpandedMainMenu():void{
            if (this.m_expandedMenu != null){
                TweenLite.to(this.m_expandedMenu, 0.2, {
                    alpha:0,
                    onComplete:this.onExpandedMenuHideTweenComplete
                });
                this.m_expandedMenu.removeEventListener(MouseEvent.MOUSE_DOWN, this.onExpandedMainMenuClick);
                Global.stage.removeEventListener(MouseEvent.MOUSE_DOWN, this.onActionMenuStageClick);
            };
        }
        private function onExpandedMenuHideTweenComplete():void{
            this.m_expandedMenu.hide();
        }
        private function onActionMenuClick(_arg1:UIEvent):void{
            this.setActionMenuMode(_arg1.label);
            this.hideExpandedMainMenu();
            this.m_bExpandedMenuOpen = false;
        }
        public function updateToolIcon(_arg1:GameMode):void{
            this.switchDefaultActionButton(_arg1.uiMode);
        }
        private function onActionMenuStageClick(_arg1:MouseEvent):void{
            if (((((!((_arg1.target == this.m_expandedMenu))) && (!((_arg1.target == this.m_defaultModeButton))))) && (!((_arg1.target == this.m_giftModeButton))))){
                this.hideExpandedMainMenu();
                this.m_bExpandedMenuOpen = false;
            };
        }
        public function resetActionMenu():void{
            this.setActionMenuMode(UIEvent.CURSOR);
        }
        private function setActionMenuMode(_arg1:String, _arg2:Boolean=false):void{
            var _local3:Boolean;
            switch (_arg1){
                case UIEvent.MOVE:
                    Global.world.addGameMode(new GMEditMove());
                    Sounds.play("click2");
                    break;
                case UIEvent.ROTATE:
                    Global.world.addGameMode(new GMEditRotate());
                    Sounds.play("click2");
                    break;
                case UIEvent.REMOVE:
                    Global.world.addGameMode(new GMEditSell());
                    Sounds.play("click2");
                    break;
                case UIEvent.STORE:
                    Global.world.addGameMode(new GMEditStore());
                    Sounds.play("click2");
                    break;
                case UIEvent.CURSOR:
                    Global.world.setDefaultGameMode();
                    if (!_arg2){
                        Sounds.play("click2");
                    };
                    break;
                case UIEvent.SHOW_COLLECTIONS:
                    UI.displayCollections();
                    _local3 = false;
                    break;
                case UIEvent.SHOW_INVENTORY:
                    UI.displayInventory();
                    _local3 = false;
                    break;
                case UIEvent.SHOW_FRANCHISE:
                    _local3 = false;
                    if (Global.franchiseManager.getFranchiseCount()){
                        UI.displayNewFranchise(false);
                    } else {
                        displayMessage(ZLoc.t("Dialogs", "NoFranchises"));
                    };
                    break;
            };
            if (_local3 == true){
                this.switchDefaultActionButton(_arg1);
            } else {
                Sounds.play("click2");
            };
        }
        public function get toaster():ToasterManager{
            return (this.m_toasterManager);
        }
        public function get happinessPanel():CityHappinessPanel{
            return (this.m_cityHappinessPanel);
        }
        public function showBuildMenu(_arg1:Boolean):void{
        }
        public function setEditMode(_arg1:Boolean):void{
            var _local4:MapResource;
            var _local2:Boolean = Global.world.isEditMode;
            if (((!(_local2)) && (_arg1))){
                Global.world.addGameMode(new GMDefault());
                this.showBuildMenu(true);
            };
            if (((_local2) && (!(_arg1)))){
                this.showBuildMenu(false);
                Global.world.addGameMode(new GMPlay());
            };
            var _local3:Array = Global.world.getObjectsByClass(MapResource);
            for each (_local4 in _local3) {
                _local4.onEditModeSwitch();
            };
        }
        private function initializeToolTip(_arg1:IToolTipTarget):void{
            if (!this.m_toolTip){
                this.m_toolTip = new ToolTipDialog(_arg1.getToolTipStatus());
                Global.stage.addChild(this.m_toolTip);
                this.m_toolTip.show();
                this.m_toolTip.mouseEnabled = (this.m_toolTip.mouseChildren = false);
            };
        }
        public function setToolTip(_arg1:IToolTipTarget):void{
            if (this.m_toolTip){
                this.m_toolTip.loadToolTipForTarget(_arg1);
            };
            this.m_toolTip.mouseEnabled = (this.m_toolTip.mouseChildren = false);
        }
        private function setToolTipHelper(_arg1:IToolTipTarget):void{
            this.initializeToolTip(_arg1);
            var _local2:ToolTipSchema = ToolTipSchema.getSchemaForObject(_arg1);
            this.m_toolTip.setToolTipSchema(_local2);
            this.setToolTip(_arg1);
        }
        public function cleanUpToolTip():void{
            if (this.m_toolTip){
                this.m_toolTip.parent.removeChild(this.m_toolTip);
            };
            this.m_toolTip = null;
            this.m_toolTipTarget = null;
        }
        public function updateToolTipPosition():void{
            var _local1:Point;
            var _local2:Vector2;
            var _local3:Vector3;
            var _local4:int;
            var _local5:Vector3;
            var _local6:Vector2;
            if (((this.m_toolTip) && (this.m_toolTipTarget))){
                if (this.m_toolTipTarget.toolTipFollowsMouse()){
                    _local1 = new Point(Global.stage.mouseX, Global.stage.mouseY);
                    _local2 = this.getCurrentCursorDimensions();
                    if (_local2){
                        _local1.x = (_local1.x + _local2.x);
                    };
                    _local1.x = (_local1.x + this.TOOLTIP_OFFSET_X);
                    _local1.x = (_local1.x + CURSOR_OFFSET_X);
                    _local1.y = (_local1.y + CURSOR_OFFSET_Y);
                    if (((_local1.x + CURSOR_OFFSET_X) + this.m_toolTip.width) > Global.stage.stageWidth){
                        _local1.x = ((Global.stage.mouseX - CURSOR_OFFSET_X) - this.m_toolTip.width);
                    };
                    if (((_local1.y + CURSOR_OFFSET_Y) + this.m_toolTip.height) > Global.stage.stageHeight){
                        _local1.y = ((Global.stage.mouseY - CURSOR_OFFSET_Y) - this.m_toolTip.height);
                    };
                } else {
                    _local3 = this.m_toolTipTarget.getDimensions();
                    if (_local3){
                        _local4 = Global.gameSettings.getNumber("maxZoom");
                        _local5 = this.m_toolTipTarget.getToolTipPosition();
                        _local1 = IsoMath.tilePosToPixelPos(_local5.x, _local5.y);
                        _local1 = IsoMath.viewportToStage(_local1);
                        _local6 = this.m_toolTipTarget.getToolTipScreenOffset();
                        if (_local6){
                            _local1.x = (_local1.x + _local6.x);
                            _local1.y = (_local1.y + _local6.y);
                        };
                        _local1.x = (_local1.x - (this.m_toolTip.width / 2));
                        _local1.y = (_local1.y - (((_local3.y * GlobalEngine.viewport.getZoom()) / _local4) + this.m_toolTip.height));
                        _local1.y = (_local1.y - ((this.m_toolTipTarget.getToolTipFloatOffset() * GlobalEngine.viewport.getZoom()) / 4));
                        if ((((((this.m_toolTipTarget is ConstructionSite)) && ((this.m_toolTipTarget as ConstructionSite).isAccelerating))) && ((this.m_toolTipTarget as ConstructionSite).actionBar))){
                            _local1.y = ((this.m_toolTipTarget as ConstructionSite).actionBar.y - this.m_toolTip.height);
                        };
                        if ((((this.m_toolTipTarget is ConstructionSite)) && (((this.m_toolTipTarget as ConstructionSite).targetClass == Bridge)))){
                            _local1.x = (_local1.x + ((((_local3.x / 2) - (this.m_toolTip.width / 3)) * GlobalEngine.viewport.getZoom()) / _local4));
                            _local1.y = (_local1.y + ((((_local3.y / 2) + this.m_toolTip.height) * GlobalEngine.viewport.getZoom()) / _local4));
                        };
                    };
                };
                if (((_local1) && (((!((_local1.x == this.m_toolTip.x))) || (!((_local1.y == this.m_toolTip.y))))))){
                    this.m_toolTip.x = _local1.x;
                    this.m_toolTip.y = _local1.y;
                };
                if (this.m_toolTip.y < 0){
                    this.m_toolTip.y = 0;
                } else {
                    if ((this.m_toolTip.y + this.m_toolTip.height) > Global.stage.stageHeight){
                        this.m_toolTip.y = (Global.stage.stageHeight - this.m_toolTip.height);
                    };
                };
                if (this.m_toolTip.x < 0){
                    this.m_toolTip.x = 0;
                } else {
                    if ((this.m_toolTip.x + this.m_toolTip.width) > Global.stage.stageWidth){
                        this.m_toolTip.x = (Global.stage.stageWidth - this.m_toolTip.width);
                    };
                };
            };
        }
        public function showToolTip(_arg1:IToolTipTarget):void{
            if (((!((_arg1 == this.m_toolTipTarget))) && (_arg1.getToolTipVisibility()))){
                this.setToolTipHelper(_arg1);
                this.m_tooltipTimer = 0;
                this.m_toolTipTarget = _arg1;
            };
        }
        public function hideToolTip(_arg1:IToolTipTarget):void{
            if (_arg1 == this.m_toolTipTarget){
                this.hideAnyToolTip();
            };
        }
        public function hideAnyToolTip():void{
            var _local1:GameObject;
            this.m_tooltipTimer = 0;
            this.m_toolTipTarget = null;
            if ((Global.world.getTopGameMode() is GMObjectMove)){
                _local1 = (Global.world.getTopGameMode() as GMObjectMove).getSelectedObject();
                if (_local1){
                    Global.ui.showToolTip(_local1);
                };
            };
        }
        public function updateToolTip(_arg1:Number):void{
            if (this.m_toolTipTarget){
                this.m_tooltipTimer = (this.m_tooltipTimer + _arg1);
                this.setToolTipHelper(this.m_toolTipTarget);
                this.updateToolTipPosition();
            };
            var _local2:Number = Global.gameSettings.getAttribute("toolTipAppearTime", this.DEFAULT_TOOL_TIP_APPEAR_TIME);
            _local2 = ((_local2)>this.MIN_TOOL_TIP_APPEAR_TIME) ? _local2 : this.MIN_TOOL_TIP_APPEAR_TIME;
            if (((this.m_toolTipTarget) && ((this.m_tooltipTimer >= _local2)))){
                if (((this.m_toolTip) && (this.m_toolTip.hasData()))){
                    this.m_toolTip.visible = true;
                };
            } else {
                if (this.m_toolTip){
                    this.m_toolTip.visible = false;
                };
            };
            if ((((this.m_toolTipTarget is MapResource)) && ((this.m_toolTipTarget as MapResource).isBeingDragged()))){
                if (((this.m_toolTip) && (this.m_toolTip.hasData()))){
                    this.m_toolTip.visible = true;
                };
            };
        }
        public function getCursorId():int{
            return (this.m_cursorId);
        }
        public function setCursorId(_arg1:int):void{
            this.m_cursorId = _arg1;
        }
        protected function createQuickButtons():void{
            var _local1 = 400;
            this.m_home = new SpriteButton(EmbeddedArt.home_Button, EmbeddedArt.home_Button, EmbeddedArt.home_Button, this.onGoHome);
            this.m_home.x = -45;
            this.m_home.y = -45;
            this.m_home.visible = false;
            this.m_home.toolTip = ZLoc.t("Main", "ReturnHome_ToolTip");
            this.m_settingsMenu.addChild(this.m_home);
            var _local2:StrokeTextField = new StrokeTextField(0, 0.8);
            _local2.toolTipText = ZLoc.t("Main", "GoHome");
            _local2.setTextFormat(new TextFormat(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 14, 0xFFFFFF, true));
            _local2.setTextFormat(_local2.defaultTextFormat);
            _local2.embedFonts = true;
            _local2.autoSize = TextFieldAutoSize.LEFT;
            _local2.x = ((this.m_home.width - _local2.textWidth) / 2);
            _local2.y = -(_local2.textHeight);
            this.m_home.addChild(_local2);
        }
        protected function onMaskBitmapEvent(_arg1:MouseEvent):void{
            var _local2:uint;
            var _local3:uint;
            if (this.m_neighborBackground){
                _local2 = this.m_neighborBackground.bitmapData.getPixel32(this.m_neighborBackground.mouseX, this.m_neighborBackground.mouseY);
                _local3 = ((_local2 >> 24) & 0xFF);
                if (_local3 < 32){
                    GlobalEngine.viewport.dispatchEvent(new MouseEvent(_arg1.type, _arg1.bubbles, _arg1.cancelable, GlobalEngine.viewport.mouseX, GlobalEngine.viewport.mouseY, GlobalEngine.viewport, _arg1.ctrlKey, _arg1.altKey, _arg1.shiftKey, _arg1.buttonDown, _arg1.delta));
                } else {
                    if (UI.hasCursor(this.m_cursorId) == false){
                        this.m_cursorId = UI.setCursor(null);
                    };
                };
            };
        }
        protected function onMouseOver(_arg1:Event):void{
            this.m_tooltipTimer = 0;
            if (!Global.ui.turnOffHighlightedObject()){
                if (UI.hasCursor(this.m_cursorId) == false){
                    this.m_cursorId = UI.setCursor(null);
                };
            };
            UI.pushBlankCursor();
        }
        protected function onMouseOut(_arg1:Event):void{
            if (!this.bNeighborButtonMenuOn){
                this.m_tooltipTimer = 0;
                UI.removeCursor(this.m_cursorId);
                UI.popBlankCursor();
            };
        }
        public function setFriendBarPos(_arg1:int):void{
            this.m_friendBar.x = (this.m_friendBarX + (FriendBar.SLOT_WIDTH * _arg1));
            ASwingHelper.prepare(this.m_friendBar);
        }
        private function onFriendBarLoaded(_arg1:FriendBarEvent):void{
            var _local2:Number = 7;
            var _local3:Number = (FriendBar.SLOT_WIDTH + 5);
            this.m_friendBar.x = (this.m_friendBarX = ((_local2 * _local3) - _arg1.length));
        }
        private function onFullscreenClick(_arg1:MouseEvent):void{
            SettingsMenu.handleFullscreenToggle();
        }
        private function onZoomInClick(_arg1:MouseEvent):void{
            var _local2:Number;
            if (Global.world.isZoomEnabled()){
                _local2 = GlobalEngine.viewport.getZoom();
                _local2 = (_local2 + Global.gameSettings.getNumber("zoomStep"));
                _local2 = Math.min(Global.gameSettings.getNumber("maxZoom"), _local2);
                _local2 = Math.max(Global.gameSettings.getNumber("minZoom"), _local2);
                StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.SETTINGS, "zoom_in");
                if (GlobalEngine.viewport.getZoom() == _local2){
                    return;
                };
                GlobalEngine.viewport.setZoom(_local2);
                Global.world.updateWorldObjectCulling(GameWorld.CULL_ZOOM_IN);
                CloudManager.updateZoomFactor(_local2);
            };
        }
        private function onZoomOutClick(_arg1:MouseEvent):void{
            var _local2:Number;
            var _local3:Vector2;
            if (Global.world.isZoomEnabled()){
                _local2 = GlobalEngine.viewport.getZoom();
                _local2 = (_local2 - Global.gameSettings.getNumber("zoomStep"));
                _local2 = Math.min(Global.gameSettings.getNumber("maxZoom"), _local2);
                _local2 = Math.max(Global.gameSettings.getNumber("minZoom"), _local2);
                StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.SETTINGS, "zoom_out");
                if (GlobalEngine.viewport.getZoom() == _local2){
                    return;
                };
                GlobalEngine.viewport.setZoom(_local2);
                _local3 = GlobalEngine.viewport.getScrollPosition();
                _local3 = GameMode.limitBackgroundScrolling(_local3);
                GlobalEngine.viewport.setScrollPosition(_local3);
                Global.world.updateWorldObjectCulling(GameWorld.CULL_ZOOM_OUT);
                CloudManager.updateZoomFactor(_local2);
            };
        }
        private function onTakePhotoClick(_arg1:MouseEvent):void{
            Global.world.addGameMode(new GMSnapShot(), true);
        }
        private function onAllAssetsLoaded(_arg1:Event):void{
            dispatchEvent(new Event(Event.COMPLETE));
        }
        private function onNeighborBarVisitClick(_arg1:FriendTradeEvent):void{
            var _local2:String = _arg1.m_friend.uid;
            if (((!((_local2 == Global.player.uid))) && (!((_local2 == Global.getVisiting()))))){
                if (!resolveIfAssetsHaveNotLoaded(DelayedAssetLoader.GENERIC_DIALOG_ASSETS)){
                    if (_arg1.m_friend.m_firstTimeVisit){
                        this.m_friendBar.friendVisited(_local2);
                    };
                    visitNeighbor(_local2);
                };
                m_catalog = null;
            };
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "visit");
        }
        private function onNeighborBarGiftClick(_arg1:FriendTradeEvent):void{
            FrameManager.navigateTo("Gifts.php?ref=neighbor_ladder");
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "gift");
        }
        private function onNeighborBarHireClick(_arg1:FriendTradeEvent):void{
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "hire");
        }
        private function onNeighborBarClick(_arg1:FriendBarSlotEvent):void{
            var _local2:Point = this.m_friendSprite.globalToLocal(_arg1.friendPoint);
            this.m_friendWindow.setActive(false);
            if (((!(_arg1.slot.m_friend.empty)) && (!((_arg1.slot.m_uid == Global.player.uid))))){
                if (this.bNeighborButtonMenuOn){
                    if (_arg1.slot.m_friend == this.neighborActionButtonMenu.friend){
                        this.removeNeighborListeners();
                        this.m_friendSprite.removeChild(this.neighborActionButtonMenu);
                        this.bNeighborButtonMenuOn = false;
                    } else {
                        this.neighborActionButtonMenu.x = (_local2.x + 40);
                        this.neighborActionButtonMenu.y = (_arg1.slot.y + 15);
                        _arg1.stopImmediatePropagation();
                        _arg1.stopPropagation();
                        this.neighborActionButtonMenu.friend = _arg1.slot.m_friend;
                    };
                } else {
                    this.neighborActionButtonMenu = new NeighborVisitGiftHireMenu(_arg1.slot.m_friend);
                    this.neighborActionButtonMenu.addEventListener(FriendTradeEvent.GIFT, this.onNeighborBarGiftClick, false, 0, true);
                    this.neighborActionButtonMenu.addEventListener(FriendTradeEvent.HIRE, this.onNeighborBarHireClick, false, 0, true);
                    this.neighborActionButtonMenu.addEventListener(FriendTradeEvent.VISIT, this.onNeighborBarVisitClick, false, 0, true);
                    this.neighborActionButtonMenu.addEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver, false, 0, true);
                    this.neighborActionButtonMenu.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut, false, 0, true);
                    this.neighborActionButtonMenu.x = (_local2.x + 40);
                    this.neighborActionButtonMenu.y = (_arg1.slot.y + 15);
                    this.bNeighborButtonMenuOn = true;
                    this.m_friendSprite.addChild(this.neighborActionButtonMenu);
                };
                StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.NEIGHBOR_LADDER, "on_picture");
            };
        }
        private function onNeighborBarRollover(_arg1:FriendBarSlotEvent):void{
            if (((this.neighborActionButtonMenu) && (this.m_friendSprite.contains(this.neighborActionButtonMenu)))){
                this.removeNeighborListeners();
                this.m_friendSprite.removeChild(this.neighborActionButtonMenu);
            };
            this.bNeighborButtonMenuOn = false;
            Global.stage.addEventListener(MouseEvent.CLICK, this.onClickedOutsideNeighbors, false, 0, true);
        }
        private function removeNeighborListeners():void{
            this.neighborActionButtonMenu.removeEventListener(FriendTradeEvent.GIFT, this.onNeighborBarGiftClick);
            this.neighborActionButtonMenu.removeEventListener(FriendTradeEvent.HIRE, this.onNeighborBarHireClick);
            this.neighborActionButtonMenu.removeEventListener(FriendTradeEvent.VISIT, this.onNeighborBarVisitClick);
            this.neighborActionButtonMenu.removeEventListener(MouseEvent.MOUSE_OVER, this.onMouseOver);
        }
        private function onClickedOutsideNeighbors(_arg1:MouseEvent):void{
            this.removeNeighborActions(_arg1);
        }
        private function removeNeighborActions(_arg1:MouseEvent):void{
            if (((this.neighborActionButtonMenu) && (this.m_friendSprite.contains(this.neighborActionButtonMenu)))){
                this.removeNeighborListeners();
                this.m_friendSprite.removeChild(this.neighborActionButtonMenu);
                this.bNeighborButtonMenuOn = false;
            };
        }
        private function onMenuClicked(_arg1:MouseEvent):void{
            var _local2:String;
            var _local3:URLRequest;
            var _local4:URLVariables;
            if (Global.disableMenu){
                return;
            };
            var _local5:ContextMenuItem = ((_arg1.target is ContextMenuItem)) ? (_arg1.target as ContextMenuItem) : null;
            if (((_local5) && (_local5.action))){
                switch (_local5.action){
                    case this.SEND_GIFT_TO:
                        _local4 = new URLVariables();
                        _local4.rId = Global.player.snUser.uid;
                        GlobalEngine.socialNetwork.redirect(("gifts.php?ref=neighborBar&giftRecipient=" + this.m_clickedSlot.uid));
                        break;
                    case this.SEND_GIFT:
                        _local4 = new URLVariables();
                        _local4.rId = Global.player.snUser.uid;
                        GlobalEngine.socialNetwork.redirect("gifts.php?ref=neigborBarNoRecipient");
                        break;
                    case this.ADD_NEIGHBOR:
                        _local4 = new URLVariables();
                        _local4.rId = this.m_clickedSlot.uid;
                        _local4.src = Global.player.snUser.uid;
                        GlobalEngine.socialNetwork.redirect("invite.php?ref=neighborsInvitePage&", _local4);
                        break;
                    case this.VISIT_NEIGHBOR:
                        visitNeighbor(this.m_clickedSlot.uid);
                        break;
                    case this.SEND_MESSAGE_NEIGHBOR:
                        break;
                };
            };
        }
        private function onLoadComplete(_arg1:Event):void{
            _arg1.currentTarget.content.width = 760;
        }
        private function onResize(_arg1:Event):void{
            this.m_bottomUI.y = (Global.stage.stageHeight - 600);
            var _local2:Number = this.x;
            this.x = ((GlobalEngine.stage.stageWidth - this.m_initialWidth) / 2);
            var _local3:Number = this.x;
            var _local4:Number = (_local2 - _local3);
            var _local5:Number = (GlobalEngine.stage.stageHeight - 245);
            var _local6:int = Math.floor((_local5 / 70));
            var _local7:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_ICON_ALIGNMENT);
            if ((((_local7 == 1)) || ((_local7 == 3)))){
                this.m_leftQuestIconLayer.x = (this.m_leftQuestIconLayer.x + _local4);
            };
            if ((((_local7 == 2)) || ((_local7 == 3)))){
                this.m_rightQuestIconLayer.x = (this.m_rightQuestIconLayer.x - _local4);
            };
            Global.hud.markDirty();
            if (((!((_arg1 == null))) && (!((Global.guide == null))))){
                Global.guide.onResize();
            };
        }
        public function delayPopup(_arg1:Number, _arg2:DisplayObject, _arg3:Boolean=true, _arg4:String="", _arg5:Boolean=false):void{
            if (_arg2 == null){
                return;
            };
            _arg2.name = _arg4;
            setTimeout(this.doDelayedPopup, _arg1, _arg2, _arg3, _arg5, Global.isVisiting());
        }
        private function doDelayedPopup(_arg1:DisplayObject, _arg2:Boolean, _arg3:Boolean, _arg4:Boolean):void{
            if (_arg1 == null){
                return;
            };
            if (Global.isVisiting() != _arg4){
                return;
            };
            displayPopup(_arg1, _arg2, _arg1.name, _arg3);
        }
        public function displayLightbox(_arg1:Boolean, _arg2:int=0, _arg3:Boolean=false):void{
            var origin:* = null;
            var g:* = null;
            var show:* = _arg1;
            var level:int = _arg2;
            var transparent:Boolean = _arg3;
            if (((show) && ((this.m_lightboxOverlay == null)))){
                this.m_lightboxOverlay = new Sprite();
                switch (level){
                    case MASK_GAME:
                    default:
                        addChildAt(this.m_lightboxOverlay, 0);
                        break;
                    case MASK_GAME_AND_BOTTOMBAR:
                        addChildAt(this.m_lightboxOverlay, (numChildren - 1));
                        this.m_lightboxOverlay.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                        break;
                    case MASK_ALL_UI:
                        addChild(this.m_lightboxOverlay);
                        setChildIndex(this.m_lightboxOverlay, (numChildren - 1));
                        this.m_lightboxOverlay.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                };
                origin = this.m_lightboxOverlay.globalToLocal(new Point(0, 0));
                g = this.m_lightboxOverlay.graphics;
                g.clear();
                if (transparent){
                    g.beginFill(0, 0);
                } else {
                    g.beginFill(0, 0.75);
                };
                g.drawRect(origin.x, origin.y, stage.stageWidth, stage.stageHeight);
                g.endFill();
                TweenLite.from(this.m_lightboxOverlay, 0.3, {alpha:0});
            };
            if (((!(show)) && (!((this.m_lightboxOverlay == null))))){
                TweenLite.to(this.m_lightboxOverlay, 0.3, {
                    alpha:0,
                    onComplete:function ():void{
                        removeChild(m_lightboxOverlay);
                        m_lightboxOverlay.removeEventListener(MouseEvent.CLICK, onMaskClicked);
                        m_lightboxOverlay = null;
                    }
                });
            };
        }
        private function onMaskClicked(_arg1:MouseEvent):void{
            _arg1.stopPropagation();
        }
        protected function getCurrentCursorDimensions():Vector2{
            if (((m_currentCursor) && (m_currentCursor.displayObj))){
                return (new Vector2(m_currentCursor.displayObj.width, m_currentCursor.displayObj.height));
            };
            return (null);
        }
        private function settingsToggleClickHandler(_arg1:UIEvent):void{
            this.m_settingsMenu.setInTransition();
            if (this.m_settingsMenu.isEnabled){
                TweenLite.to(this.m_settingsMenu, 0.5, {
                    y:-30,
                    onComplete:this.settingsMenuTweenCompleteHandler
                });
            } else {
                TweenLite.to(this.m_settingsMenu, 0.5, {
                    y:-117,
                    onComplete:this.settingsMenuTweenCompleteHandler
                });
            };
        }
        private function settingsMenuTweenCompleteHandler():void{
            this.m_settingsMenu.isEnabled = !(this.m_settingsMenu.isEnabled);
            if (Global.guide.isActive()){
                this.m_settingsMenu.setEndTransition();
            } else {
                this.m_settingsMenu.setEndPostTutorialTransition();
            };
        }
        protected function isHighQualityGraphics():Boolean{
            return (!((Global.stage.quality == StageQuality.LOW)));
        }
        private function onGoHome(_arg1:Event):void{
            if (((Global.player) && (Global.player.uid))){
                GameTransactionManager.addTransaction(new TWorldLoad(Global.player.uid), true, true);
            };
            Global.setVisiting(null);
            this.updateVisitMode(false);
            m_catalog = null;
            if (Global.mission){
                Global.postInitActions.execute();
                Global.mission = null;
            };
            if (Global.guide){
                Global.guide.cleanup();
            };
        }
        private function onBuyModeClick(_arg1:MouseEvent):void{
            if (Global.disableMenu){
                return;
            };
            this.hideExpandedMainMenu();
            if (Global.isVisiting()){
                return;
            };
            UI.displayCatalog(null);
            Sounds.play("click2");
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.MODE_BUTTON, "market");
        }
        private function onDefaultModeClick(_arg1:MouseEvent):void{
            if (this.m_bExpandedMenuOpen == true){
                this.hideExpandedMainMenu();
                this.m_bExpandedMenuOpen = false;
            } else {
                this.m_bExpandedMenuOpen = this.displayExpandedMainMenu(ExpandedMainMenu);
                Sounds.play("UI_expandmenu");
            };
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.MODE_BUTTON, "action_menu");
        }
        private function onGiftModeClick(_arg1:MouseEvent):void{
            if (this.m_bExpandedMenuOpen == true){
                this.hideExpandedMainMenu();
                this.m_bExpandedMenuOpen = false;
            } else {
                this.m_bExpandedMenuOpen = this.displayExpandedMainMenu(ExpandedInventoryMenu);
                Sounds.play("UI_expandmenu");
            };
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.MODE_BUTTON, "gifts");
        }
        private function onNewsModeClick(_arg1:MouseEvent):void{
            this.reconfigureSettingsMenu();
            if (this.m_bExpandedMenuOpen == true){
                this.hideExpandedMainMenu();
                this.m_bExpandedMenuOpen = false;
            } else {
                this.m_bExpandedMenuOpen = this.displayExpandedMainMenu(ExpandedInventoryMenu);
                Sounds.play("UI_expandmenu");
            };
            StatsManager.sample(100, StatsCounterType.HUD_COUNTER, StatsKingdomType.MODE_BUTTON, "storage_menu");
            this.switchDefaultActionButton(UIEvent.CURSOR);
        }
        private function onCancelModeClick(_arg1:MouseEvent):void{
            this.hideExpandedMainMenu();
            Global.world.addGameMode(new GMPlay());
        }
        public function updateVisitMode(_arg1:Boolean):void{
            this.m_home.visible = _arg1;
        }
        public function get bottomUI():Sprite{
            return (this.m_bottomUI);
        }
        public function getBottomRight():Point{
            var _local1:Rectangle = this.m_bottomUI.getBounds(Global.stage);
            var _local2:Point = new Point((_local1.x + _local1.width), ((_local1.y + _local1.height) - 75));
            return (_local2);
        }
        public function displayOverlaySWF(_arg1:String, _arg2:Point=null, _arg3:Vector2=null, _arg4:Number=0, _arg5:Function=null):void{
            var _local6:Loader = LoadingManager.load(_arg1, this.playOverlaySWF);
            this.m_overlaySWFs[_local6] = {
                scale:_arg3,
                position:_arg2,
                yOffset:_arg4,
                callback:_arg5
            };
        }
        private function playOverlaySWF(_arg1:Event):void{
            var _local3:MovieClip;
            var _local4:Object;
            var _local5:Point;
            var _local6:Vector2;
            var _local7:Number;
            var _local8:Number;
            var _local9:SoundTransform;
            var _local2:Loader = (_arg1.target.loader as Loader);
            if (_local2 != null){
                _local3 = (_local2.content as MovieClip);
                if (Global.player.options.sfxDisabled){
                    _local9 = new SoundTransform();
                    _local9.volume = 0;
                    _local3.soundTransform = _local9;
                };
                _local4 = (this.m_overlaySWFs[_local2] as Object);
                _local5 = (_local4.position as Point);
                _local6 = (_local4.scale as Vector2);
                _local7 = (_local4.yOffset as Number);
                _local8 = 0;
                if (_local6 != null){
                    _local8 = (_local6.x / _local2.contentLoaderInfo.width);
                    _local2.scaleX = _local8;
                    _local2.scaleY = _local8;
                };
                if (_local5 != null){
                    if (_local6 != null){
                        _local2.x = _local5.x;
                        _local2.y = (_local5.y - (_local7 * ((_local2.contentLoaderInfo.height * _local8) - _local6.y)));
                    } else {
                        _local2.x = _local5.x;
                        _local2.y = _local5.y;
                    };
                };
                if (_local3.origin_mc){
                    _local2.x = (_local2.x - _local3.origin_mc.x);
                    _local2.y = (_local2.y - _local3.origin_mc.y);
                };
                GlobalEngine.viewport.uiBase.addChild(_local2);
                _local3.play();
                _local3.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);
            };
        }
        private function onEnterFrame(_arg1:Event):void{
            var _local2:Loader = (_arg1.target.parent as Loader);
            var _local3:MovieClip = (_local2.content as MovieClip);
            if (_local3.currentFrame >= _local3.totalFrames){
                _local3.stop();
                if (_local2.parent != null){
                    _local2.parent.removeChild(_local2);
                };
                if (this.m_overlaySWFs[_local2].callback != null){
                    this.m_overlaySWFs[_local2].callback();
                };
                delete this.m_overlaySWFs[_local2];
                _local3.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
            };
        }
        public function displayPopupAd(_arg1:DisplayObject, _arg2:String="popupAd", _arg3:int=0):void{
            _arg1.name = _arg2;
            addChildAt(_arg1, 0);
            var _local4:Dialog = (_arg1 as Dialog);
            if (_local4){
                _local4.show();
            };
        }
        public function swapPopupAd(_arg1:String, _arg2:Boolean=true):void{
            var popupName:* = _arg1;
            var front:Boolean = _arg2;
            try {
                if (front){
                    this.setChildIndex(getChildByName(popupName), (this.numChildren - 1));
                } else {
                    this.setChildIndex(getChildByName(popupName), 0);
                };
            } catch(error:Error) {
            };
        }
        public function setExpandMode(_arg1:Boolean):void{
            if (_arg1){
                UI.displayCatalog("expansion");
            };
        }
        public function turnOffHighlightedObject():Boolean{
            var _local2:GMDefault;
            var _local1:GameMode = Global.world.getTopGameMode();
            if ((_local1 is GMDefault)){
                _local2 = (_local1 as GMDefault);
                _local2.turnOffObject();
                return (true);
            };
            return (false);
        }
        public function get collectionView():CollectionView{
            return (m_collections);
        }
        public function get inventoryView():InventoryView{
            return (m_inventory);
        }
        public function get franchiseMenu():FranchiseMenu{
            return (m_franchiseMenu);
        }
        public function get isActionMenuOpen():Boolean{
            return (this.m_bExpandedMenuOpen);
        }

    }
}//package Display 
